This is a limitation of the Zend engine that I encountered earlier, especially when using socket_select() / stream_select() , for which both arguments to the “resource array” are passed by reference. It would be nice to assign the values of the variables that will be passed by reference in one line, but it is not possible (at present) to do this.
I already mentioned this before ( although right now I cannot find where (here here ), and perhaps it was not authoritative) that any expression in PHP is evaluated on the right side of the expression. By this I mean:
$a = 1; $b = 2; echo $a = $b;
This will be echo 2 , because the expression that was passed by the echo operator evaluates to the right side of the expression $b , which is 2 .
When passing the result of a function expression, for example, c( $o = b() ); where you pass the result $o = b(); to the c() function, I understand (although I could be wrong) that the result of the expression is passed to the function and the function is executed before zval is created and assigned to store $o , a behavior that was designed to reduce memory consumption and speed up internal processing, when functions are nested this way. This means that you did not actually pass the variable by reference, you just passed the value obtained from b() , the right side of the expression, which cannot be changed by reference, because it does not have a container variable.
In fact, if you enable E_STRICT messages, you will see the following error:
Strict standards: only variables should be passed by reference in ...
... therefore this behavior is truly "by design".
source share