Parameter %d must be passed by reference¶
Description¶
When a parameter is set to be passed by reference, there is a &
character before its name. In that case, the argument must be a data container, such as a variable, a property, a static property, an array index, but it cannot be a literal value, a constant, or the result of an expression.
Example¶
<?php
function foo(&$a) {}
// invalid cases
foo(1);
foo(1 + 2);
const A = 1;
foo(A);
class X {
const B = 2;
}
foo(X::B);
?>
Literal Examples¶
foo(): Argument #1 ($a) must be passed by reference, value given
Solutions¶
Store the value in a variable and passe the variable.
Remove the reference in the method signature.