@@ -2852,7 +2852,7 @@ keyed-list-expression-list:
28522852
28532853list-or-variable:
28542854 list-intrinsic
2855- variable
2855+ '&'? variable
28562856-->
28572857
28582858<pre >
@@ -2874,7 +2874,7 @@ list-or-variable:
28742874
28752875<i id =" grammar-list-or-variable " >list-or-variable:</i >
28762876 <i ><a href =" #grammar-list-intrinsic " >list-intrinsic</a ></i >
2877- <i ><a href =" #grammar-variable " >variable</a ></i >
2877+ & amp ; < sub >opt</ sub > <i ><a href =" #grammar-variable " >variable</a ></i >
28782878</pre >
28792879
28802880** Constraints**
@@ -2892,7 +2892,8 @@ At least one of the elements of the *list-expression-list* must be non-empty.
28922892** Semantics**
28932893
28942894This intrinsic assigns one or more elements of the source array to the
2895- target variables. On success, it returns a copy of the source array. If the
2895+ target variables. Target variables may be assigned by reference.
2896+ On success, it will return a copy of the source array. If the
28962897source array is not an array or object implementing ` ArrayAccess ` no
28972898assignments are performed and the return value is ` NULL ` .
28982899
@@ -2942,6 +2943,12 @@ list($arr[1], $arr[0]) = [0, 1];
29422943list($arr2[], $arr2[]) = [0, 1];
29432944 // $arr2 is [0, 1]
29442945
2946+ $a = [1, 2];
2947+ list(& $one, $two) = $a;
2948+ // $a[0] is 1, $a[1] is 2
2949+ $one++;
2950+ // $a[0] is 2, $a[1] is 2
2951+
29452952list("one" => $one, "two" => $two) = ["one" => 1, "two" => 2];
29462953 // $one is 1, $two is 2
29472954list(
@@ -2952,6 +2959,13 @@ list(
29522959 "two" => 2,
29532960];
29542961 // $one is 1, $two is 2
2962+
2963+ $a = ['one' => 1, 'two' => 2];
2964+ list('one' => & $one, 'two' => $two) = $a;
2965+ // $a['one'] is 1, $a['two'] is 2
2966+ $one++;
2967+ // $a['one'] is 2, $a['two'] is 2
2968+
29552969list(list("x" => $x1, "y" => $y1), list("x" => $x2, "y" => $y2)) = [
29562970 ["x" => 1, "y" => 2],
29572971 ["x" => 3, "y" => 4]
0 commit comments