Returning by reference from a void function is deprecated¶
Description¶
The return type void
means that no value is returned, not even NULL. This means that the &
option has no value here. Since PHP 8.1, this is reported as deprecated.
In the end, it has no value to collect the returned value of a void function, reference or not.
Example¶
<?php
function &foo() : void { }
?>
Solutions¶
Do not collect the returned valueo of a void function.
Remove the reference in the method definition.