From: Operating system: PHP version: 5.3.3RC2 Package: SPL related Bug Type: Feature/Change Request Bug description:spl_get_object_by_hash()
Description: ------------ class a{} $object = new a(); $object2 = spl_get_object_by_hash(spl_object_hash($object)); var_dump($object === $object2); // true (same object) NOTE: When using spl_get_object_by_hash, you must know that $object must be alive else function can return another object. Primary usage example in test script: Test script: --------------- class a{ protected $_b; public function getB(){ return spl_get_object_by_hash($this->_b); } public function doSomething(){ $b = $this->getB(); // here I can use $b ! } public function __construct($b){ $this->_b = spl_object_hash($b); } } class b{ protected $_a; public function getA(){ return $this->_a; } public function __construct(){ $this->_a = new a($this); } public function __destruct(){ echo 'destroyed'; } } $b = new b(); $b->getA()->doSomething(); unset($b); // destroyed !! this IS NOT POSSIBLE without spl_get_object_by_hash() -- Edit bug report at http://bugs.php.net/bug.php?id=52300&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52300&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52300&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52300&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52300&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52300&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52300&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52300&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52300&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52300&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52300&r=support Expected behavior: http://bugs.php.net/fix.php?id=52300&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52300&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52300&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52300&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52300&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52300&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52300&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52300&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52300&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52300&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52300&r=mysqlcfg