summaryrefslogtreecommitdiff
path: root/Zend/tests/bug64555.phpt
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2013-04-03 20:29:19 +0200
committerNikita Popov <nikic@php.net>2013-04-03 20:29:19 +0200
commit1f34ccbe34783f5671bc2a68e7299cea7493c82b (patch)
treec87e035f6c12793b54b53bd24391fa0ef67fad80 /Zend/tests/bug64555.phpt
parent42f94aa9783c72411336dfc39a8b7335cb45854c (diff)
downloadphp-git-1f34ccbe34783f5671bc2a68e7299cea7493c82b.tar.gz
Fix bug #64555: foreach no longer copies keys if they are interned
Diffstat (limited to 'Zend/tests/bug64555.phpt')
-rw-r--r--Zend/tests/bug64555.phpt42
1 files changed, 42 insertions, 0 deletions
diff --git a/Zend/tests/bug64555.phpt b/Zend/tests/bug64555.phpt
new file mode 100644
index 0000000000..d5226af7a9
--- /dev/null
+++ b/Zend/tests/bug64555.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Bug #64555: Array key within interned string gets wrong hash value
+--FILE--
+<?php
+
+class Foo {
+ protected $unsetme = 1;
+ protected $keepme = 2;
+
+ public function test() {
+ $a = get_object_vars($this);
+
+ foreach ($a as $k => $v) {
+ if ($k == 'unsetme') {
+ echo "Unsetting: $k\n";
+ unset($a[$k]);
+ } else if ($k == 'keepme') {
+ echo "Changing: $k\n";
+ $a[$k] = 42;
+ $a['keepme'] = 43;
+ }
+ }
+
+ var_dump($a, array_keys($a));
+ }
+}
+
+$f = new Foo;
+$f->test();
+
+?>
+--EXPECT--
+Unsetting: unsetme
+Changing: keepme
+array(1) {
+ ["keepme"]=>
+ int(43)
+}
+array(1) {
+ [0]=>
+ string(6) "keepme"
+}