![Krzysztof N.](https://static.goldenline.pl/user_hidden_basic.jpg)
Krzysztof
N.
CEO. Aplikacje
internetowe i
mobilne. Symfony,
Zend.
Temat: spl_object_hash() - taki sam hash dla różnych obiektów?
Taka sytuacja:$original = new My\Namespace\MyObject();Dlaczego $hash1 i $hash2 są identyczne?
$object1 = clone $original;
$object2 = clone $original;
$hash1 = spl_object_hash($object1);
$hash2 = spl_object_hash($object2);
lub inaczej:
Kiedy, w jakich przypadkach, $hash1 i $hash2 mogą być identyczne?
Bazując na dokumentacji funkcji spl_object_hash()
wiemy, że:
When an object is destroyed, its hash may be reused for other objects.oraz że:
Uniqueness is not guaranteed between objects that did not reside in memory simultaneously, for example:tylko to nie rozwiązuje problemu.
var_dump(spl_object_hash(new stdClass()), spl_object_hash(new stdClass()));
Jakie macie pomysły? :]