note 80898 deleted from language.oop5.overloading by danielc
| From: | danielc@php.net | Date: | Fri, 28 Aug 2009 03:37:55 +0000 |
| Subject: | note 80898 deleted from language.oop5.overloading by danielc | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-159974@lists.php.net to get a copy of this message | ||
Note Submitter: Hayley Watson
Reason: 0
----
Chained assignments are still right-associative and still work as expected. That is to say, $a =
$foo->b = $c is equivalent to $a = ($foo->b = $c) and results in $a being set to the value of
$c even if $foo->b is a property handled by __get/__set and even if those methods adjust/validate
their arguments (and even if they fail).
In other words, "$a = $b = $c;" and "$a = ($b = $c);" are both equivalent to
"$a = $c; $b = $c;" and not to the equally plausible "$b = $c; $a = $b;".
Assignment expressions evaluate to the value that gets assigned - the value that appears on the
right-hand side - and what happens to whatever is on the left is treated as a side-effect.
So in the expression $a=$b=$c, $a doesn't care about what does or doesn't happen to $b -
all it sees is the *value* of $b=$c, which is just the value of $c. The parentheses make this
clearer: in $a=($b=$c) we have $b being assigned the value of $c and $a being assigned the value of
($b=$c).
As already hinted, this is nothing new: it's just made more obvious by __get and __set: $a =
$foo->b = $c does NOT involve looking up the value of $foo->b (let alone assigning it to $a),
and $foo->__get() isn't called.