#30413 [Opn->Bgs]: __set called for wrong object

From: Date: Wed, 13 Oct 2004 07:19:46 +0000
Subject: #30413 [Opn->Bgs]: __set called for wrong object
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-67517@lists.php.net to get a copy of this message
ID: 30413 Updated by: derick@php.net Reported By: info at pandora-web dot de -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: Linux 2.6 PHP Version: 5.0.2 New Comment: Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Thank you for your interest in PHP. Please add your information to bug #28444 then, closing this one as a "submitted twice" bug. Derick Previous Comments: ------------------------------------------------------------------------ [2004-10-12 23:26:35] info at pandora-web dot de see bug #28444 This is just another test case. Please correct this odd behavior. Thanx ------------------------------------------------------------------------ [2004-10-12 19:14:00] info at pandora-web dot de Description: ------------ When using overloaded Objects in Overloaded Object, then the __set method of the first object is called instead of the last Object in chain. Reproduce code: --------------- class TestClass { private $_p = array(); public function __get($propName){ return $this->_p[$propName]; } public function __set($propName, $propValue){ $this->_p[$propName] = $value; } } $a = new TestClass(); $a->TestVar = 'test'; print $a->testVar; //--> 'test' $a->testVar = new TestClass(); $a->testVar->testVar = 'test2'; // __set of $a->testVar called instead of getter of $a->testVar and setter of $a->testVar->testVar Expected result: ---------------- I think I is better to call the __get method of the first objects and than the __set method of the last one in chain. Actual result: -------------- <br /> <b>Fatal error</b>: Cannot access undefined property for object with overloaded property access in <b>xxxx</b> on line <b>xxxx</b><br /> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=30413&edit=1

« previous php.bugs (#67517) next »