xref: /PHP-8.2/Zend/tests/bug64555.phpt (revision 782352c5)
1--TEST--
2Bug #64555: Array key within interned string gets wrong hash value
3--FILE--
4<?php
5
6class Foo {
7    protected $unsetme = 1;
8    protected $keepme = 2;
9
10    public function test() {
11        $a = get_object_vars($this);
12
13        foreach ($a as $k => $v) {
14            if ($k == 'unsetme') {
15                echo "Unsetting: $k\n";
16                unset($a[$k]);
17            } else if ($k == 'keepme') {
18                echo "Changing: $k\n";
19                $a[$k] = 42;
20                $a['keepme'] = 43;
21            }
22        }
23
24        var_dump($a, array_keys($a));
25    }
26}
27
28$f = new Foo;
29$f->test();
30
31?>
32--EXPECT--
33Unsetting: unsetme
34Changing: keepme
35array(1) {
36  ["keepme"]=>
37  int(43)
38}
39array(1) {
40  [0]=>
41  string(6) "keepme"
42}
43