diff options
author | Nikita Popov <nikic@php.net> | 2013-04-03 20:29:19 +0200 |
---|---|---|
committer | Nikita Popov <nikic@php.net> | 2013-04-03 20:29:19 +0200 |
commit | 1f34ccbe34783f5671bc2a68e7299cea7493c82b (patch) | |
tree | c87e035f6c12793b54b53bd24391fa0ef67fad80 /Zend/tests/bug64555.phpt | |
parent | 42f94aa9783c72411336dfc39a8b7335cb45854c (diff) | |
download | php-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.phpt | 42 |
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" +} |