summaryrefslogtreecommitdiff
path: root/Zend/tests
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-01-26 12:50:28 +0100
committerNikita Popov <nikita.ppv@gmail.com>2021-01-26 12:51:02 +0100
commit776726da0387daa190b2a27733800a556f6dc4b6 (patch)
tree84469af804cb0b3ec58af0b4b51cc16016814821 /Zend/tests
parent1954e5975846b3952ce1d2d6506e6d7134c89684 (diff)
downloadphp-git-776726da0387daa190b2a27733800a556f6dc4b6.tar.gz
Add missing resource key warning for unset()
It was present on other operations, including isset(), but was missing for unset().
Diffstat (limited to 'Zend/tests')
-rw-r--r--Zend/tests/resource_key.phpt36
1 files changed, 36 insertions, 0 deletions
diff --git a/Zend/tests/resource_key.phpt b/Zend/tests/resource_key.phpt
new file mode 100644
index 0000000000..fddd41bcad
--- /dev/null
+++ b/Zend/tests/resource_key.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Behavior of resources as array keys
+--FILE--
+<?php
+
+$r = fopen(__FILE__, 'r');
+$a = [];
+echo "Assign:";
+$a[$r] = 1;
+echo "Add assign:";
+$a[$r] += 1;
+echo "Inc:";
+$a[$r]++;
+echo "Get:";
+var_dump($a[$r]);
+echo "Isset:";
+var_dump(isset($a[$r]));
+echo "Unset:";
+unset($a[$r]);
+
+?>
+--EXPECTF--
+Assign:
+Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
+Add assign:
+Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
+Inc:
+Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
+Get:
+Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
+int(3)
+Isset:
+Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
+bool(true)
+Unset:
+Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d