1Spread array
2-----
3<?php
4$array = [1, 2, 3];
5
6function getArr() {
7	return [4, 5];
8}
9
10function arrGen() {
11	for($i = 11; $i < 15; $i++) {
12		yield $i;
13	}
14}
15
16[...[]];
17[...[1, 2, 3]];
18[...$array];
19[...getArr()];
20[...arrGen()];
21[...new ArrayIterator(['a', 'b', 'c'])];
22[0, ...$array, ...getArr(), 6, 7, 8, 9, 10, ...arrGen()];
23[0, ...$array, ...$array, 'end'];
24-----
25array(
26    0: Stmt_Expression(
27        expr: Expr_Assign(
28            var: Expr_Variable(
29                name: array
30            )
31            expr: Expr_Array(
32                items: array(
33                    0: ArrayItem(
34                        key: null
35                        value: Scalar_Int(
36                            value: 1
37                        )
38                        byRef: false
39                        unpack: false
40                    )
41                    1: ArrayItem(
42                        key: null
43                        value: Scalar_Int(
44                            value: 2
45                        )
46                        byRef: false
47                        unpack: false
48                    )
49                    2: ArrayItem(
50                        key: null
51                        value: Scalar_Int(
52                            value: 3
53                        )
54                        byRef: false
55                        unpack: false
56                    )
57                )
58            )
59        )
60    )
61    1: Stmt_Function(
62        attrGroups: array(
63        )
64        byRef: false
65        name: Identifier(
66            name: getArr
67        )
68        params: array(
69        )
70        returnType: null
71        stmts: array(
72            0: Stmt_Return(
73                expr: Expr_Array(
74                    items: array(
75                        0: ArrayItem(
76                            key: null
77                            value: Scalar_Int(
78                                value: 4
79                            )
80                            byRef: false
81                            unpack: false
82                        )
83                        1: ArrayItem(
84                            key: null
85                            value: Scalar_Int(
86                                value: 5
87                            )
88                            byRef: false
89                            unpack: false
90                        )
91                    )
92                )
93            )
94        )
95    )
96    2: Stmt_Function(
97        attrGroups: array(
98        )
99        byRef: false
100        name: Identifier(
101            name: arrGen
102        )
103        params: array(
104        )
105        returnType: null
106        stmts: array(
107            0: Stmt_For(
108                init: array(
109                    0: Expr_Assign(
110                        var: Expr_Variable(
111                            name: i
112                        )
113                        expr: Scalar_Int(
114                            value: 11
115                        )
116                    )
117                )
118                cond: array(
119                    0: Expr_BinaryOp_Smaller(
120                        left: Expr_Variable(
121                            name: i
122                        )
123                        right: Scalar_Int(
124                            value: 15
125                        )
126                    )
127                )
128                loop: array(
129                    0: Expr_PostInc(
130                        var: Expr_Variable(
131                            name: i
132                        )
133                    )
134                )
135                stmts: array(
136                    0: Stmt_Expression(
137                        expr: Expr_Yield(
138                            key: null
139                            value: Expr_Variable(
140                                name: i
141                            )
142                        )
143                    )
144                )
145            )
146        )
147    )
148    3: Stmt_Expression(
149        expr: Expr_Array(
150            items: array(
151                0: ArrayItem(
152                    key: null
153                    value: Expr_Array(
154                        items: array(
155                        )
156                    )
157                    byRef: false
158                    unpack: true
159                )
160            )
161        )
162    )
163    4: Stmt_Expression(
164        expr: Expr_Array(
165            items: array(
166                0: ArrayItem(
167                    key: null
168                    value: Expr_Array(
169                        items: array(
170                            0: ArrayItem(
171                                key: null
172                                value: Scalar_Int(
173                                    value: 1
174                                )
175                                byRef: false
176                                unpack: false
177                            )
178                            1: ArrayItem(
179                                key: null
180                                value: Scalar_Int(
181                                    value: 2
182                                )
183                                byRef: false
184                                unpack: false
185                            )
186                            2: ArrayItem(
187                                key: null
188                                value: Scalar_Int(
189                                    value: 3
190                                )
191                                byRef: false
192                                unpack: false
193                            )
194                        )
195                    )
196                    byRef: false
197                    unpack: true
198                )
199            )
200        )
201    )
202    5: Stmt_Expression(
203        expr: Expr_Array(
204            items: array(
205                0: ArrayItem(
206                    key: null
207                    value: Expr_Variable(
208                        name: array
209                    )
210                    byRef: false
211                    unpack: true
212                )
213            )
214        )
215    )
216    6: Stmt_Expression(
217        expr: Expr_Array(
218            items: array(
219                0: ArrayItem(
220                    key: null
221                    value: Expr_FuncCall(
222                        name: Name(
223                            name: getArr
224                        )
225                        args: array(
226                        )
227                    )
228                    byRef: false
229                    unpack: true
230                )
231            )
232        )
233    )
234    7: Stmt_Expression(
235        expr: Expr_Array(
236            items: array(
237                0: ArrayItem(
238                    key: null
239                    value: Expr_FuncCall(
240                        name: Name(
241                            name: arrGen
242                        )
243                        args: array(
244                        )
245                    )
246                    byRef: false
247                    unpack: true
248                )
249            )
250        )
251    )
252    8: Stmt_Expression(
253        expr: Expr_Array(
254            items: array(
255                0: ArrayItem(
256                    key: null
257                    value: Expr_New(
258                        class: Name(
259                            name: ArrayIterator
260                        )
261                        args: array(
262                            0: Arg(
263                                name: null
264                                value: Expr_Array(
265                                    items: array(
266                                        0: ArrayItem(
267                                            key: null
268                                            value: Scalar_String(
269                                                value: a
270                                            )
271                                            byRef: false
272                                            unpack: false
273                                        )
274                                        1: ArrayItem(
275                                            key: null
276                                            value: Scalar_String(
277                                                value: b
278                                            )
279                                            byRef: false
280                                            unpack: false
281                                        )
282                                        2: ArrayItem(
283                                            key: null
284                                            value: Scalar_String(
285                                                value: c
286                                            )
287                                            byRef: false
288                                            unpack: false
289                                        )
290                                    )
291                                )
292                                byRef: false
293                                unpack: false
294                            )
295                        )
296                    )
297                    byRef: false
298                    unpack: true
299                )
300            )
301        )
302    )
303    9: Stmt_Expression(
304        expr: Expr_Array(
305            items: array(
306                0: ArrayItem(
307                    key: null
308                    value: Scalar_Int(
309                        value: 0
310                    )
311                    byRef: false
312                    unpack: false
313                )
314                1: ArrayItem(
315                    key: null
316                    value: Expr_Variable(
317                        name: array
318                    )
319                    byRef: false
320                    unpack: true
321                )
322                2: ArrayItem(
323                    key: null
324                    value: Expr_FuncCall(
325                        name: Name(
326                            name: getArr
327                        )
328                        args: array(
329                        )
330                    )
331                    byRef: false
332                    unpack: true
333                )
334                3: ArrayItem(
335                    key: null
336                    value: Scalar_Int(
337                        value: 6
338                    )
339                    byRef: false
340                    unpack: false
341                )
342                4: ArrayItem(
343                    key: null
344                    value: Scalar_Int(
345                        value: 7
346                    )
347                    byRef: false
348                    unpack: false
349                )
350                5: ArrayItem(
351                    key: null
352                    value: Scalar_Int(
353                        value: 8
354                    )
355                    byRef: false
356                    unpack: false
357                )
358                6: ArrayItem(
359                    key: null
360                    value: Scalar_Int(
361                        value: 9
362                    )
363                    byRef: false
364                    unpack: false
365                )
366                7: ArrayItem(
367                    key: null
368                    value: Scalar_Int(
369                        value: 10
370                    )
371                    byRef: false
372                    unpack: false
373                )
374                8: ArrayItem(
375                    key: null
376                    value: Expr_FuncCall(
377                        name: Name(
378                            name: arrGen
379                        )
380                        args: array(
381                        )
382                    )
383                    byRef: false
384                    unpack: true
385                )
386            )
387        )
388    )
389    10: Stmt_Expression(
390        expr: Expr_Array(
391            items: array(
392                0: ArrayItem(
393                    key: null
394                    value: Scalar_Int(
395                        value: 0
396                    )
397                    byRef: false
398                    unpack: false
399                )
400                1: ArrayItem(
401                    key: null
402                    value: Expr_Variable(
403                        name: array
404                    )
405                    byRef: false
406                    unpack: true
407                )
408                2: ArrayItem(
409                    key: null
410                    value: Expr_Variable(
411                        name: array
412                    )
413                    byRef: false
414                    unpack: true
415                )
416                3: ArrayItem(
417                    key: null
418                    value: Scalar_String(
419                        value: end
420                    )
421                    byRef: false
422                    unpack: false
423                )
424            )
425        )
426    )
427)
428