Only variable references should be returned by reference

Description

When a function returns a reference, it must return a variable, a property or an array’s item. It cannot return a literal value, a constant or an expression.

Example

<?php

function &foo() {
    return 1;

    return B;
}

?>

Solutions

  • Put the literal in a variable, and return the variable.

  • Remove the reference in the method signature.