ID: 35651 Updated by: [EMAIL PROTECTED] Reported By: tomas_matousek at hotmail dot com -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: WinXP PHP Version: 5.1.1 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php __set() and __get() are called only if such property doesn't exist. Previous Comments: ------------------------------------------------------------------------ [2005-12-12 21:20:26] tomas_matousek at hotmail dot com Description: ------------ In the following example, the __setter invoked by $x->a = "g1"; statement tries to write to "a" property again by $this->a = "a"; statement in the switch. This latter access is correctly considered to be recursive and thus treated as assignment to $this->a and not as a recursive call. That's ok. However, after returning from the __setter and when invoking it again by $x->b = "g2"; the $this->a = "b"; should call the __setter because we it is not a recursive call ("b" was accessed, not "a"). Hence $this->a = "b"; should invoke __setter in this case. And that doesn't happen. Reproduce code: --------------- class C { function __set($f,$v) { echo "set('$f','$v')\n"; switch ($f) { case "a": $this->a = "a"; break; case "b": $this->a = "b"; break; } } } $x = new C; $x->a = "g1"; // this blocks "a" on $x forever $x->b = "g2"; Expected result: ---------------- set('a','g1') set('b','g2') set('a','b') Actual result: -------------- set('a','g1') set('b','g2') ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=35651&edit=1