Return Reference On Void
There are methods that return void; and methods that return a reference. Until PHP 8.1, they could be the same, although a Notice was emitted. This is now deprecated behavior in PHP 8.1, and shall disappear in PHP 9.
PHP code
<?php
function &foo() : void {
echo __METHOD__;
return;
}
foo();
?>
Before
fooPHP Notice: Only variable references should be returned by reference
Notice: Only variable references should be returned by reference
After
PHP Deprecated: Returning by reference from a void function is deprecated
Deprecated: Returning by reference from a void function is deprecated
fooPHP Notice: Only variable references should be returned by reference
Notice: Only variable references should be returned by reference
PHP version change
This behavior was deprecated in 8.1.
This behavior changed in 9.0.