Cannot assign reference to non referenceable value

Description

It is possible to assign values by references, only when the right operand is already stored in a variable, or similar.

Example

<?php

list(&$x) = [1, 2];

$array = [1,2];
list(&$x, ) = $array

?>

Solutions

  • Store the operand in a variable (or equivalent).

  • Assign values individually.