summaryrefslogtreecommitdiff
path: root/Zend/tests/illegal_offset_unset_isset_empty.phpt
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-09-26 17:04:43 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-09-27 13:00:07 +0200
commit2354aa96761781507f238bd075eb59ca82e19705 (patch)
tree6a30a7dbb37cd608025d8717302ea54f6a687c82 /Zend/tests/illegal_offset_unset_isset_empty.phpt
parent0ebf2bdba0eb6510d7d397d1d826cfe7f9525ad1 (diff)
downloadphp-git-2354aa96761781507f238bd075eb59ca82e19705.tar.gz
Add test for illegal unset/isset offset
Weirdly these warnings had zero coverage previously... Remove an incorrect exception checking optimization: The key lookup may throw (it could also throw previously, though only through a custom error handler).
Diffstat (limited to 'Zend/tests/illegal_offset_unset_isset_empty.phpt')
-rw-r--r--Zend/tests/illegal_offset_unset_isset_empty.phpt27
1 files changed, 27 insertions, 0 deletions
diff --git a/Zend/tests/illegal_offset_unset_isset_empty.phpt b/Zend/tests/illegal_offset_unset_isset_empty.phpt
new file mode 100644
index 0000000000..9005053e67
--- /dev/null
+++ b/Zend/tests/illegal_offset_unset_isset_empty.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Using unset(), isset(), empty() with an illegal array offset throws
+--FILE--
+<?php
+
+$ary = [];
+try {
+ unset($ary[[]]);
+} catch (Error $e) {
+ echo $e->getMessage(), "\n";
+}
+try {
+ isset($ary[[]]);
+} catch (Error $e) {
+ echo $e->getMessage(), "\n";
+}
+try {
+ empty($ary[[]]);
+} catch (Error $e) {
+ echo $e->getMessage(), "\n";
+}
+
+?>
+--EXPECT--
+Illegal offset type in unset
+Illegal offset type in isset or empty
+Illegal offset type in isset or empty