@@ -2852,7 +2852,7 @@ keyed-list-expression-list:
2852
2852
2853
2853
list-or-variable:
2854
2854
list-intrinsic
2855
- variable
2855
+ '&'? variable
2856
2856
-->
2857
2857
2858
2858
<pre >
@@ -2874,7 +2874,7 @@ list-or-variable:
2874
2874
2875
2875
<i id =" grammar-list-or-variable " >list-or-variable:</i >
2876
2876
<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 >
2878
2878
</pre >
2879
2879
2880
2880
** Constraints**
@@ -2892,7 +2892,8 @@ At least one of the elements of the *list-expression-list* must be non-empty.
2892
2892
** Semantics**
2893
2893
2894
2894
This 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
2896
2897
source array is not an array or object implementing ` ArrayAccess ` no
2897
2898
assignments are performed and the return value is ` NULL ` .
2898
2899
@@ -2942,6 +2943,12 @@ list($arr[1], $arr[0]) = [0, 1];
2942
2943
list($arr2[], $arr2[]) = [0, 1];
2943
2944
// $arr2 is [0, 1]
2944
2945
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
+
2945
2952
list("one" => $one, "two" => $two) = ["one" => 1, "two" => 2];
2946
2953
// $one is 1, $two is 2
2947
2954
list(
@@ -2952,6 +2959,13 @@ list(
2952
2959
"two" => 2,
2953
2960
];
2954
2961
// $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
+
2955
2969
list(list("x" => $x1, "y" => $y1), list("x" => $x2, "y" => $y2)) = [
2956
2970
["x" => 1, "y" => 2],
2957
2971
["x" => 3, "y" => 4]
0 commit comments