#32913 [NEW]: properties via __get and __set methods in one expression won't work

From: Date: Mon, 02 May 2005 12:11:26 +0000
Subject: #32913 [NEW]: properties via __get and __set methods in one expression won't work
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-78521@lists.php.net to get a copy of this message
From: marius at distance dot ktu dot lt Operating system: Linux PHP version: 5.0.3 PHP Bug Type: Class/Object related Bug description: properties via __get and __set methods in one expression won't work Description: ------------ Note: you might say this is a duplicate of #28444, but i don't think it's not a bug so please read carefully what i've written before doing that and if you say it's a duplicate, please explain specificaly why... thanks. --- when i traverse object tree with overloaded properties, i can't assign a value to complex properties (i.e. $a->b->c). i don't see why this should be a problem for php... I don't get why do you say it's not a bug? Consider my reproduce code. why do the first and second property accessors work and the third (final) one does not? as i understand the final statement ($a->a->a = "";) should do: $a->__get("a")->__set("a", ""); so what's wrong with that? no recursive __get or __set, everything should work by specification... or am i wrong? if so, where? Reproduce code: --------------- <?php class A { function __get($name) { return new A(); } function __set($name, $value) { } } $a= new A(); $a->a->a; // only __get = ok $a->a = ""; // only __set = ok $a->a->a = ""; // __get and __set = error ?> Expected result: ---------------- the code should work ok. Actual result: -------------- Fatal error: Cannot access undefined property for object with overloaded property access in test.php on line 15 this error only happens if php would need to call __get and __set of some classes (sequentially not recursively) to resolve one (lhs) expression. -- Edit bug report at http://bugs.php.net/?id=32913&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32913&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32913&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32913&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=32913&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=32913&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=32913&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=32913&r=needscript Try newer version: http://bugs.php.net/fix.php?id=32913&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=32913&r=support Expected behavior: http://bugs.php.net/fix.php?id=32913&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=32913&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=32913&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=32913&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32913&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=32913&r=dst IIS Stability: http://bugs.php.net/fix.php?id=32913&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=32913&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=32913&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=32913&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=32913&r=mysqlcfg

« previous php.bugs (#78521) next »