|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-12-12 21:28 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 08:00:02 2025 UTC |
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')