%s(): Returning by reference from a void function is deprecated

Description

The void type means that the function is not returning anything. So, it doesn’t matter if that nothing is returned by value or by reference.

If the returned value is, nonetheless, collected, it will be null in any case.

Example

<?php

    function &foo(): void { }

?>

Literal Examples

  • foo(): Returning by reference from a void function is deprecated

Solutions

  • Remove the reference of the function.

  • Remove the type void, and return an actual value.

Changed Behavior

This error may appear following an evolution in behavior, in previous versions. See return_reference_on_void.php.

Static Analysis

This error may be tracked down with the following static analysis rules: Structures/ReturnVoid.