#31884 [NEW]: setting reference to $this in class method

From: Date: Tue, 08 Feb 2005 13:47:14 +0000
Subject: #31884 [NEW]: setting reference to $this in class method
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-73649@lists.php.net to get a copy of this message
From: camka at email dot ee Operating system: Linux PHP version: 5.0.3 PHP Bug Type: Zend Engine 2 problem Bug description: setting reference to $this in class method Description: ------------ When setting reference to $this object, using "=&" operator in a class method doesn't seem to work as expected (or my understanding is completely wrong). When unsetting object outside of the class methods - link breaks and won't unset the referenced objects. Reproduce code: --------------- <?php class uu { public $ref; public function set_me_as_ref(uu &$whom) { $whom->ref = &$this; } } $obj1 = new uu(); $obj2 = new uu(); $obj2->set_me_as_ref($obj1); $obj2 = null; // this won't unset $obj1->ref, but unsets only $obj2 object // $obj1->ref = null; // this won't unset the $obj2 object, but unsets only $obj1->ref echo '<pre>'; var_dump($obj1, $obj2); ?> Expected result: ---------------- $obj1->ref is supposed to be null $obje2 - is supposed to be null Actual result: -------------- $obj1->ref => living object $obj2 => null -- Edit bug report at http://bugs.php.net/?id=31884&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31884&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31884&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31884&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=31884&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=31884&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=31884&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=31884&r=needscript Try newer version: http://bugs.php.net/fix.php?id=31884&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=31884&r=support Expected behavior: http://bugs.php.net/fix.php?id=31884&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=31884&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=31884&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=31884&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31884&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=31884&r=dst IIS Stability: http://bugs.php.net/fix.php?id=31884&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=31884&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=31884&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=31884&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=31884&r=mysqlcfg

« previous php.bugs (#73649) next »