#31683 [Opn->Asn]: changes to $name in __get($name) override future parameters

From: Date: Tue, 25 Jan 2005 09:07:24 +0000
Subject: #31683 [Opn->Asn]: changes to $name in __get($name) override future parameters
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-72774@lists.php.net to get a copy of this message
ID: 31683 Updated by: tony2001@php.net Reported By: wagner at bonn dot edu -Status: Open +Status: Assigned Bug Type: Zend Engine 2 problem Operating System: Gentoo Linux PHP Version: 5CVS-2005-01-25 (dev) -Assigned To: +Assigned To: dmitry Previous Comments: ------------------------------------------------------------------------ [2005-01-25 01:50:28] wagner at bonn dot edu Description: ------------ Changing $name in __get($name) to e.g. "foo", will cause the next call of __get() to use "foo" as the name instead of the name of the member-Variable that was actually called. Only intercepted accesses to variables (e.g. $obj->doesnt_exist) seem to be affected, not direct calls to __get() (e.g. $obj->__get("whatever") ); Reproducible with PHP 5.0.3, PHP_5_0 CVS and CVS head (PHP 5.1 dev). Reproduce code: --------------- <?php class testclass { public function __get($name) { echo "$name \n"; $name = "wrong"; } } $obj = new testclass(); for ($i=1; $i <=3; $i++) { $dummy = $obj->correct; } ?> Expected result: ---------------- correct correct correct The line $name = "wrong"; should have no effect. Actual result: -------------- correct wrong wrong ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31683&edit=1

« previous php.bugs (#72774) next »