Chained Assignation Skips __get()

../_images/chained_assignation.png

Chained assignation skip the get part and assign the same value to all elements in the chain.

When chained assignations are done with variables, the value in the variable is the same as the value out of it: the engine might optimise the work and use the same rightmost value everywhere.

Yet, PHP has dynamic properties, since… a long time ago, and again, with property hooks in PHP 8.4: there, the incoming value may be changed between the set function and the get one. Here, the get is skipped.

In the end, it might be logical, but may also surprise the coder too.

See Also

PHP Features