public
Created

  • Download Gist
gistfile1.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
--TEST--
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"
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.