This warning happens whenever you assign a reference to a property to another property. There's a similar warning if you assign an array reference to an array element, e.g.
$array[$x] = &$array[$y];
The reason for these warnings is that the order of creation changed in PHP 7. This is explained in the following from https://github.com/php/php-src/blob/PHP-7.0/UPGRADING
Array elements or object properties that are automatically created during
by-reference assignments will now result in a different order. For example
$array = [];
$array["a"] =& $array["b"];
$array["b"] = 1;
var_dump($array);
now results in the array ["a" => 1, "b" => 1]
, while previously the result
was ["b" => 1, "a" => 1]
;
Relevant RFCs:
Unless you actually care about the order of properties in an object or the order of elements in an associative array, this warning can be ignored. If you need the old order, you need to ensure that the property on the right has already been created before the assignment.
I don't think there's a way to suppress it, other than by disabling all warnings by using --level=error
. Even if the code does create the RHS property first, I expect you'll get the warning during the assignment, since I doubt it can do the level of semantic analysis to tell whether the property is new.