Short-circuiting is not allowed where the result is being used as a parameter that would be passed to a function by reference.
Consider this code:
function takes_ref(&$foo)
{
// ...
}
takes_ref($foo?->bar);
Expanding it to the equivalent code without using null shortcircuiting, it would be:
function takes_ref(&$foo) {
// ...
}
if ($foo != null) {
takes_ref($foo->bar);
}
else {
takes_ref(null);
}
However that code is not valid, as it would give an error "Fatal error: Only variables can be passed by reference" whenever $foo
was null.