1Error recovery
2-----
3<?php
4
5foo()
6bar()
7baz()
8-----
9Syntax error, unexpected T_STRING from 4:1 to 4:3
10Syntax error, unexpected T_STRING from 5:1 to 5:3
11Syntax error, unexpected EOF from 5:6 to 5:6
12array(
13    0: Stmt_Expression(
14        expr: Expr_FuncCall(
15            name: Name(
16                name: foo
17            )
18            args: array(
19            )
20        )
21    )
22    1: Stmt_Expression(
23        expr: Expr_FuncCall(
24            name: Name(
25                name: bar
26            )
27            args: array(
28            )
29        )
30    )
31    2: Stmt_Expression(
32        expr: Expr_FuncCall(
33            name: Name(
34                name: baz
35            )
36            args: array(
37            )
38        )
39    )
40)
41-----
42<?php
43
44foo()
45bar();
46baz();
47-----
48Syntax error, unexpected T_STRING from 4:1 to 4:3
49array(
50    0: Stmt_Expression(
51        expr: Expr_FuncCall(
52            name: Name(
53                name: foo
54            )
55            args: array(
56            )
57        )
58    )
59    1: Stmt_Expression(
60        expr: Expr_FuncCall(
61            name: Name(
62                name: bar
63            )
64            args: array(
65            )
66        )
67    )
68    2: Stmt_Expression(
69        expr: Expr_FuncCall(
70            name: Name(
71                name: baz
72            )
73            args: array(
74            )
75        )
76    )
77)
78-----
79<?php
80
81foo();
82bar()
83baz();
84-----
85Syntax error, unexpected T_STRING from 5:1 to 5:3
86array(
87    0: Stmt_Expression(
88        expr: Expr_FuncCall(
89            name: Name(
90                name: foo
91            )
92            args: array(
93            )
94        )
95    )
96    1: Stmt_Expression(
97        expr: Expr_FuncCall(
98            name: Name(
99                name: bar
100            )
101            args: array(
102            )
103        )
104    )
105    2: Stmt_Expression(
106        expr: Expr_FuncCall(
107            name: Name(
108                name: baz
109            )
110            args: array(
111            )
112        )
113    )
114)
115-----
116<?php
117abc;
1181 + ;
119-----
120Syntax error, unexpected ';' from 3:5 to 3:5
121array(
122    0: Stmt_Expression(
123        expr: Expr_ConstFetch(
124            name: Name(
125                name: abc
126            )
127        )
128    )
129    1: Stmt_Expression(
130        expr: Scalar_Int(
131            value: 1
132        )
133    )
134)
135-----
136<?php
137function test() {
138    1 +
139}
140-----
141Syntax error, unexpected '}' from 4:1 to 4:1
142array(
143    0: Stmt_Function(
144        attrGroups: array(
145        )
146        byRef: false
147        name: Identifier(
148            name: test
149        )
150        params: array(
151        )
152        returnType: null
153        stmts: array(
154            0: Stmt_Expression(
155                expr: Scalar_Int(
156                    value: 1
157                )
158            )
159        )
160    )
161)
162-----
163<?php
164
165$i = 0;
166while
167
168$j = 1;
169$k = 2;
170-----
171Syntax error, unexpected T_VARIABLE, expecting '(' from 6:1 to 6:2
172array(
173    0: Stmt_Expression(
174        expr: Expr_Assign(
175            var: Expr_Variable(
176                name: i
177            )
178            expr: Scalar_Int(
179                value: 0
180            )
181        )
182    )
183    1: Stmt_Expression(
184        expr: Expr_Assign(
185            var: Expr_Variable(
186                name: j
187            )
188            expr: Scalar_Int(
189                value: 1
190            )
191        )
192    )
193    2: Stmt_Expression(
194        expr: Expr_Assign(
195            var: Expr_Variable(
196                name: k
197            )
198            expr: Scalar_Int(
199                value: 2
200            )
201        )
202    )
203)
204-----
205<?php
206
207$i = 0;
208while () {
209    $j = 1;
210}
211$k = 2;
212// The output here drops the loop - would require Error node to handle this
213-----
214Syntax error, unexpected ')' from 4:8 to 4:8
215array(
216    0: Stmt_Expression(
217        expr: Expr_Assign(
218            var: Expr_Variable(
219                name: i
220            )
221            expr: Scalar_Int(
222                value: 0
223            )
224        )
225    )
226    1: Stmt_Block(
227        stmts: array(
228            0: Stmt_Expression(
229                expr: Expr_Assign(
230                    var: Expr_Variable(
231                        name: j
232                    )
233                    expr: Scalar_Int(
234                        value: 1
235                    )
236                )
237            )
238        )
239    )
240    2: Stmt_Expression(
241        expr: Expr_Assign(
242            var: Expr_Variable(
243                name: k
244            )
245            expr: Scalar_Int(
246                value: 2
247            )
248        )
249    )
250    3: Stmt_Nop(
251        comments: array(
252            0: // The output here drops the loop - would require Error node to handle this
253        )
254    )
255)
256-----
257<?php
258// Can't recover this yet, as the '}' for the inner_statement_list
259// is always required.
260
261$i = 0;
262while (true) {
263    $i = 1;
264    $i = 2;
265-----
266Syntax error, unexpected EOF from 8:12 to 8:12
267-----
268<?php
269$foo->
270;
271-----
272!!positions
273Syntax error, unexpected ';', expecting T_STRING or T_VARIABLE or '{' or '$' from 3:1 to 3:1
274array(
275    0: Stmt_Expression[2:1 - 3:1](
276        expr: Expr_PropertyFetch[2:1 - 2:6](
277            var: Expr_Variable[2:1 - 2:4](
278                name: foo
279            )
280            name: Expr_Error[3:1 - 2:6](
281            )
282        )
283    )
284)
285-----
286<?php
287function foo() {
288    $bar->
289}
290-----
291!!positions
292Syntax error, unexpected '}', expecting T_STRING or T_VARIABLE or '{' or '$' from 4:1 to 4:1
293array(
294    0: Stmt_Function[2:1 - 4:1](
295        attrGroups: array(
296        )
297        byRef: false
298        name: Identifier[2:10 - 2:12](
299            name: foo
300        )
301        params: array(
302        )
303        returnType: null
304        stmts: array(
305            0: Stmt_Expression[3:5 - 3:10](
306                expr: Expr_PropertyFetch[3:5 - 3:10](
307                    var: Expr_Variable[3:5 - 3:8](
308                        name: bar
309                    )
310                    name: Expr_Error[4:1 - 3:10](
311                    )
312                )
313            )
314        )
315    )
316)
317-----
318<?php
319new T
320-----
321Syntax error, unexpected EOF from 2:6 to 2:6
322array(
323    0: Stmt_Expression(
324        expr: Expr_New(
325            class: Name(
326                name: T
327            )
328            args: array(
329            )
330        )
331    )
332)
333-----
334<?php
335new
336-----
337!!positions
338Syntax error, unexpected EOF from 2:4 to 2:4
339array(
340    0: Stmt_Expression[2:1 - 2:3](
341        expr: Expr_New[2:1 - 2:3](
342            class: Expr_Error[2:4 - 2:3](
343            )
344            args: array(
345            )
346        )
347    )
348)
349-----
350<?php
351$foo instanceof
352-----
353Syntax error, unexpected EOF from 2:16 to 2:16
354array(
355    0: Stmt_Expression(
356        expr: Expr_Instanceof(
357            expr: Expr_Variable(
358                name: foo
359            )
360            class: Expr_Error(
361            )
362        )
363    )
364)
365-----
366<?php
367$
368-----
369Syntax error, unexpected EOF, expecting T_VARIABLE or '{' or '$' from 2:2 to 2:2
370array(
371    0: Stmt_Expression(
372        expr: Expr_Variable(
373            name: Expr_Error(
374            )
375        )
376    )
377)
378-----
379<?php
380Foo::$
381-----
382Syntax error, unexpected EOF, expecting T_VARIABLE or '{' or '$' from 2:7 to 2:7
383array(
384    0: Stmt_Expression(
385        expr: Expr_StaticPropertyFetch(
386            class: Name(
387                name: Foo
388            )
389            name: Expr_Error(
390            )
391        )
392    )
393)
394-----
395<?php
396Foo::
397-----
398Syntax error, unexpected EOF from 2:6 to 2:6
399array(
400    0: Stmt_Expression(
401        expr: Expr_ClassConstFetch(
402            class: Name(
403                name: Foo
404            )
405            name: Expr_Error(
406            )
407        )
408    )
409)
410-----
411<?php
412namespace Foo
413use A
414use function a
415use A\{B}
416const A = 1
417break
418break 2
419continue
420continue 2
421return
422return 2
423echo $a
424unset($a)
425throw $x
426goto label
427-----
428Syntax error, unexpected T_USE, expecting ';' or '{' from 3:1 to 3:3
429Syntax error, unexpected T_USE, expecting ';' from 5:1 to 5:3
430Syntax error, unexpected T_CONST, expecting ';' from 6:1 to 6:5
431Syntax error, unexpected T_BREAK, expecting ';' from 7:1 to 7:5
432Syntax error, unexpected T_THROW, expecting ';' from 15:1 to 15:5
433array(
434    0: Stmt_Namespace(
435        name: Name(
436            name: Foo
437        )
438        stmts: array(
439            0: Stmt_Use(
440                type: TYPE_NORMAL (1)
441                uses: array(
442                    0: UseItem(
443                        type: TYPE_UNKNOWN (0)
444                        name: Name(
445                            name: A
446                        )
447                        alias: null
448                    )
449                )
450            )
451            1: Stmt_Use(
452                type: TYPE_FUNCTION (2)
453                uses: array(
454                    0: UseItem(
455                        type: TYPE_UNKNOWN (0)
456                        name: Name(
457                            name: a
458                        )
459                        alias: null
460                    )
461                )
462            )
463            2: Stmt_GroupUse(
464                type: TYPE_UNKNOWN (0)
465                prefix: Name(
466                    name: A
467                )
468                uses: array(
469                    0: UseItem(
470                        type: TYPE_NORMAL (1)
471                        name: Name(
472                            name: B
473                        )
474                        alias: null
475                    )
476                )
477            )
478            3: Stmt_Const(
479                consts: array(
480                    0: Const(
481                        name: Identifier(
482                            name: A
483                        )
484                        value: Scalar_Int(
485                            value: 1
486                        )
487                    )
488                )
489            )
490            4: Stmt_Break(
491                num: null
492            )
493            5: Stmt_Break(
494                num: Scalar_Int(
495                    value: 2
496                )
497            )
498            6: Stmt_Continue(
499                num: null
500            )
501            7: Stmt_Continue(
502                num: Scalar_Int(
503                    value: 2
504                )
505            )
506            8: Stmt_Return(
507                expr: null
508            )
509            9: Stmt_Return(
510                expr: Scalar_Int(
511                    value: 2
512                )
513            )
514            10: Stmt_Echo(
515                exprs: array(
516                    0: Expr_Variable(
517                        name: a
518                    )
519                )
520            )
521            11: Stmt_Unset(
522                vars: array(
523                    0: Expr_Variable(
524                        name: a
525                    )
526                )
527            )
528            12: Stmt_Expression(
529                expr: Expr_Throw(
530                    expr: Expr_Variable(
531                        name: x
532                    )
533                )
534            )
535            13: Stmt_Goto(
536                name: Identifier(
537                    name: label
538                )
539            )
540        )
541    )
542)
543-----
544<?php
545
546use A\{B, };
547use function A\{b, };
548use A, ;
549const A = 42, ;
550
551class X implements Y, {
552    use A, ;
553    use A, {
554        A::b insteadof C, ;
555    }
556    const A = 42, ;
557    public $x, ;
558}
559interface I extends J, {}
560
561unset($x, );
562isset($x, );
563
564declare(a=42, );
565
566global $a, ;
567static $a, ;
568echo $a, ;
569
570for ($a, ; $b, ; $c, );
571-----
572A trailing comma is not allowed here from 5:6 to 5:6
573A trailing comma is not allowed here from 6:13 to 6:13
574A trailing comma is not allowed here from 8:21 to 8:21
575A trailing comma is not allowed here from 9:10 to 9:10
576A trailing comma is not allowed here from 10:10 to 10:10
577A trailing comma is not allowed here from 11:25 to 11:25
578A trailing comma is not allowed here from 13:17 to 13:17
579A trailing comma is not allowed here from 14:14 to 14:14
580A trailing comma is not allowed here from 16:22 to 16:22
581A trailing comma is not allowed here from 21:13 to 21:13
582A trailing comma is not allowed here from 23:10 to 23:10
583A trailing comma is not allowed here from 24:10 to 24:10
584A trailing comma is not allowed here from 25:8 to 25:8
585A trailing comma is not allowed here from 27:8 to 27:8
586A trailing comma is not allowed here from 27:14 to 27:14
587A trailing comma is not allowed here from 27:20 to 27:20
588array(
589    0: Stmt_GroupUse(
590        type: TYPE_UNKNOWN (0)
591        prefix: Name(
592            name: A
593        )
594        uses: array(
595            0: UseItem(
596                type: TYPE_NORMAL (1)
597                name: Name(
598                    name: B
599                )
600                alias: null
601            )
602        )
603    )
604    1: Stmt_GroupUse(
605        type: TYPE_FUNCTION (2)
606        prefix: Name(
607            name: A
608        )
609        uses: array(
610            0: UseItem(
611                type: TYPE_UNKNOWN (0)
612                name: Name(
613                    name: b
614                )
615                alias: null
616            )
617        )
618    )
619    2: Stmt_Use(
620        type: TYPE_NORMAL (1)
621        uses: array(
622            0: UseItem(
623                type: TYPE_UNKNOWN (0)
624                name: Name(
625                    name: A
626                )
627                alias: null
628            )
629        )
630    )
631    3: Stmt_Const(
632        consts: array(
633            0: Const(
634                name: Identifier(
635                    name: A
636                )
637                value: Scalar_Int(
638                    value: 42
639                )
640            )
641        )
642    )
643    4: Stmt_Class(
644        attrGroups: array(
645        )
646        flags: 0
647        name: Identifier(
648            name: X
649        )
650        extends: null
651        implements: array(
652            0: Name(
653                name: Y
654            )
655        )
656        stmts: array(
657            0: Stmt_TraitUse(
658                traits: array(
659                    0: Name(
660                        name: A
661                    )
662                )
663                adaptations: array(
664                )
665            )
666            1: Stmt_TraitUse(
667                traits: array(
668                    0: Name(
669                        name: A
670                    )
671                )
672                adaptations: array(
673                    0: Stmt_TraitUseAdaptation_Precedence(
674                        trait: Name(
675                            name: A
676                        )
677                        method: Identifier(
678                            name: b
679                        )
680                        insteadof: array(
681                            0: Name(
682                                name: C
683                            )
684                        )
685                    )
686                )
687            )
688            2: Stmt_ClassConst(
689                attrGroups: array(
690                )
691                flags: 0
692                type: null
693                consts: array(
694                    0: Const(
695                        name: Identifier(
696                            name: A
697                        )
698                        value: Scalar_Int(
699                            value: 42
700                        )
701                    )
702                )
703            )
704            3: Stmt_Property(
705                attrGroups: array(
706                )
707                flags: PUBLIC (1)
708                type: null
709                props: array(
710                    0: PropertyItem(
711                        name: VarLikeIdentifier(
712                            name: x
713                        )
714                        default: null
715                    )
716                )
717            )
718        )
719    )
720    5: Stmt_Interface(
721        attrGroups: array(
722        )
723        name: Identifier(
724            name: I
725        )
726        extends: array(
727            0: Name(
728                name: J
729            )
730        )
731        stmts: array(
732        )
733    )
734    6: Stmt_Unset(
735        vars: array(
736            0: Expr_Variable(
737                name: x
738            )
739        )
740    )
741    7: Stmt_Expression(
742        expr: Expr_Isset(
743            vars: array(
744                0: Expr_Variable(
745                    name: x
746                )
747            )
748        )
749    )
750    8: Stmt_Declare(
751        declares: array(
752            0: DeclareItem(
753                key: Identifier(
754                    name: a
755                )
756                value: Scalar_Int(
757                    value: 42
758                )
759            )
760        )
761        stmts: null
762    )
763    9: Stmt_Global(
764        vars: array(
765            0: Expr_Variable(
766                name: a
767            )
768        )
769    )
770    10: Stmt_Static(
771        vars: array(
772            0: StaticVar(
773                var: Expr_Variable(
774                    name: a
775                )
776                default: null
777            )
778        )
779    )
780    11: Stmt_Echo(
781        exprs: array(
782            0: Expr_Variable(
783                name: a
784            )
785        )
786    )
787    12: Stmt_For(
788        init: array(
789            0: Expr_Variable(
790                name: a
791            )
792        )
793        cond: array(
794            0: Expr_Variable(
795                name: b
796            )
797        )
798        loop: array(
799            0: Expr_Variable(
800                name: c
801            )
802        )
803        stmts: array(
804        )
805    )
806)
807-----
808<?php
809
810foo(Bar::);
811-----
812!!positions
813Syntax error, unexpected ')' from 3:10 to 3:10
814array(
815    0: Stmt_Expression[3:1 - 3:11](
816        expr: Expr_FuncCall[3:1 - 3:10](
817            name: Name[3:1 - 3:3](
818                name: foo
819            )
820            args: array(
821                0: Arg[3:5 - 3:9](
822                    name: null
823                    value: Expr_ClassConstFetch[3:5 - 3:9](
824                        class: Name[3:5 - 3:7](
825                            name: Bar
826                        )
827                        name: Expr_Error[3:10 - 3:9](
828                        )
829                    )
830                    byRef: false
831                    unpack: false
832                )
833            )
834        )
835    )
836)
837-----
838<?php
839
840class Foo {
841    public $bar1;
842    publi $foo;
843    public $bar;
844}
845-----
846Syntax error, unexpected T_STRING from 5:5 to 5:9
847array(
848    0: Stmt_Class(
849        attrGroups: array(
850        )
851        flags: 0
852        name: Identifier(
853            name: Foo
854        )
855        extends: null
856        implements: array(
857        )
858        stmts: array(
859            0: Stmt_Property(
860                attrGroups: array(
861                )
862                flags: PUBLIC (1)
863                type: null
864                props: array(
865                    0: PropertyItem(
866                        name: VarLikeIdentifier(
867                            name: bar1
868                        )
869                        default: null
870                    )
871                )
872            )
873            1: Stmt_Property(
874                attrGroups: array(
875                )
876                flags: PUBLIC (1)
877                type: null
878                props: array(
879                    0: PropertyItem(
880                        name: VarLikeIdentifier(
881                            name: bar
882                        )
883                        default: null
884                    )
885                )
886            )
887        )
888    )
889)
890-----
891<?php
892
893foreach ($foo) { $bar; }
894foreach ($foo as ) { $bar; }
895-----
896Syntax error, unexpected ')' from 3:14 to 3:14
897Syntax error, unexpected ')' from 4:18 to 4:18
898array(
899    0: Stmt_Foreach(
900        expr: Expr_Variable(
901            name: foo
902        )
903        keyVar: null
904        byRef: false
905        valueVar: Expr_Error(
906        )
907        stmts: array(
908            0: Stmt_Expression(
909                expr: Expr_Variable(
910                    name: bar
911                )
912            )
913        )
914    )
915    1: Stmt_Foreach(
916        expr: Expr_Variable(
917            name: foo
918        )
919        keyVar: null
920        byRef: false
921        valueVar: Expr_Error(
922        )
923        stmts: array(
924            0: Stmt_Expression(
925                expr: Expr_Variable(
926                    name: bar
927                )
928            )
929        )
930    )
931)
932-----
933<?php
934
935function foo(Type) {
936    $foo;
937}
938
939function foo(Type1 $foo, Type2) {
940    $bar;
941}
942
943function foo(...) {
944    $baz;
945}
946
947function foo(&) {
948    $qux;
949}
950
951function foo(Bar)
952
953class Bar {
954    function foo(Baz)
955}
956
957function(Foo);
958-----
959Syntax error, unexpected ')', expecting T_VARIABLE from 3:18 to 3:18
960Syntax error, unexpected ')', expecting T_VARIABLE from 7:31 to 7:31
961Syntax error, unexpected ')', expecting T_VARIABLE from 11:17 to 11:17
962Syntax error, unexpected T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG, expecting T_VARIABLE from 15:14 to 15:14
963Syntax error, unexpected ')', expecting T_VARIABLE from 19:17 to 19:17
964Syntax error, unexpected ')', expecting T_VARIABLE from 22:21 to 22:21
965Syntax error, unexpected ')', expecting T_VARIABLE from 25:13 to 25:13
966array(
967    0: Stmt_Function(
968        attrGroups: array(
969        )
970        byRef: false
971        name: Identifier(
972            name: foo
973        )
974        params: array(
975            0: Param(
976                attrGroups: array(
977                )
978                flags: 0
979                type: Name(
980                    name: Type
981                )
982                byRef: false
983                variadic: false
984                var: Expr_Error(
985                )
986                default: null
987            )
988        )
989        returnType: null
990        stmts: array(
991            0: Stmt_Expression(
992                expr: Expr_Variable(
993                    name: foo
994                )
995            )
996        )
997    )
998    1: Stmt_Function(
999        attrGroups: array(
1000        )
1001        byRef: false
1002        name: Identifier(
1003            name: foo
1004        )
1005        params: array(
1006            0: Param(
1007                attrGroups: array(
1008                )
1009                flags: 0
1010                type: Name(
1011                    name: Type1
1012                )
1013                byRef: false
1014                variadic: false
1015                var: Expr_Variable(
1016                    name: foo
1017                )
1018                default: null
1019            )
1020            1: Param(
1021                attrGroups: array(
1022                )
1023                flags: 0
1024                type: Name(
1025                    name: Type2
1026                )
1027                byRef: false
1028                variadic: false
1029                var: Expr_Error(
1030                )
1031                default: null
1032            )
1033        )
1034        returnType: null
1035        stmts: array(
1036            0: Stmt_Expression(
1037                expr: Expr_Variable(
1038                    name: bar
1039                )
1040            )
1041        )
1042    )
1043    2: Stmt_Function(
1044        attrGroups: array(
1045        )
1046        byRef: false
1047        name: Identifier(
1048            name: foo
1049        )
1050        params: array(
1051            0: Param(
1052                attrGroups: array(
1053                )
1054                flags: 0
1055                type: null
1056                byRef: false
1057                variadic: true
1058                var: Expr_Error(
1059                )
1060                default: null
1061            )
1062        )
1063        returnType: null
1064        stmts: array(
1065            0: Stmt_Expression(
1066                expr: Expr_Variable(
1067                    name: baz
1068                )
1069            )
1070        )
1071    )
1072    3: Stmt_Function(
1073        attrGroups: array(
1074        )
1075        byRef: false
1076        name: Identifier(
1077            name: foo
1078        )
1079        params: array(
1080            0: Param(
1081                attrGroups: array(
1082                )
1083                flags: 0
1084                type: null
1085                byRef: false
1086                variadic: false
1087                var: Expr_Error(
1088                )
1089                default: null
1090            )
1091        )
1092        returnType: null
1093        stmts: array(
1094            0: Stmt_Expression(
1095                expr: Expr_Variable(
1096                    name: qux
1097                )
1098            )
1099        )
1100    )
1101    4: Stmt_Function(
1102        attrGroups: array(
1103        )
1104        byRef: false
1105        name: Identifier(
1106            name: foo
1107        )
1108        params: array(
1109            0: Param(
1110                attrGroups: array(
1111                )
1112                flags: 0
1113                type: Name(
1114                    name: Bar
1115                )
1116                byRef: false
1117                variadic: false
1118                var: Expr_Error(
1119                )
1120                default: null
1121            )
1122        )
1123        returnType: null
1124        stmts: array(
1125        )
1126    )
1127    5: Stmt_Class(
1128        attrGroups: array(
1129        )
1130        flags: 0
1131        name: Identifier(
1132            name: Bar
1133        )
1134        extends: null
1135        implements: array(
1136        )
1137        stmts: array(
1138            0: Stmt_ClassMethod(
1139                attrGroups: array(
1140                )
1141                flags: 0
1142                byRef: false
1143                name: Identifier(
1144                    name: foo
1145                )
1146                params: array(
1147                    0: Param(
1148                        attrGroups: array(
1149                        )
1150                        flags: 0
1151                        type: Name(
1152                            name: Baz
1153                        )
1154                        byRef: false
1155                        variadic: false
1156                        var: Expr_Error(
1157                        )
1158                        default: null
1159                    )
1160                )
1161                returnType: null
1162                stmts: array(
1163                )
1164            )
1165        )
1166    )
1167    6: Stmt_Expression(
1168        expr: Expr_Closure(
1169            attrGroups: array(
1170            )
1171            static: false
1172            byRef: false
1173            params: array(
1174                0: Param(
1175                    attrGroups: array(
1176                    )
1177                    flags: 0
1178                    type: Name(
1179                        name: Foo
1180                    )
1181                    byRef: false
1182                    variadic: false
1183                    var: Expr_Error(
1184                    )
1185                    default: null
1186                )
1187            )
1188            uses: array(
1189            )
1190            returnType: null
1191            stmts: array(
1192            )
1193        )
1194    )
1195)
1196-----
1197<?php
1198$array = [
1199    $this->value $oopsAnotherValue->get()
1200];
1201$array = [
1202    $value $oopsAnotherValue
1203];
1204$array = [
1205    'key' => $value $oopsAnotherValue
1206];
1207-----
1208Syntax error, unexpected T_VARIABLE, expecting ',' or ']' or ')' from 3:18 to 3:34
1209Syntax error, unexpected T_VARIABLE, expecting ',' or ']' or ')' from 6:12 to 6:28
1210Syntax error, unexpected T_VARIABLE, expecting ',' or ']' or ')' from 9:21 to 9:37
1211array(
1212    0: Stmt_Expression(
1213        expr: Expr_Assign(
1214            var: Expr_Variable(
1215                name: array
1216            )
1217            expr: Expr_Array(
1218                items: array(
1219                    0: ArrayItem(
1220                        key: null
1221                        value: Expr_PropertyFetch(
1222                            var: Expr_Variable(
1223                                name: this
1224                            )
1225                            name: Identifier(
1226                                name: value
1227                            )
1228                        )
1229                        byRef: false
1230                        unpack: false
1231                    )
1232                    1: ArrayItem(
1233                        key: null
1234                        value: Expr_MethodCall(
1235                            var: Expr_Variable(
1236                                name: oopsAnotherValue
1237                            )
1238                            name: Identifier(
1239                                name: get
1240                            )
1241                            args: array(
1242                            )
1243                        )
1244                        byRef: false
1245                        unpack: false
1246                    )
1247                )
1248            )
1249        )
1250    )
1251    1: Stmt_Expression(
1252        expr: Expr_Assign(
1253            var: Expr_Variable(
1254                name: array
1255            )
1256            expr: Expr_Array(
1257                items: array(
1258                    0: ArrayItem(
1259                        key: null
1260                        value: Expr_Variable(
1261                            name: value
1262                        )
1263                        byRef: false
1264                        unpack: false
1265                    )
1266                    1: ArrayItem(
1267                        key: null
1268                        value: Expr_Variable(
1269                            name: oopsAnotherValue
1270                        )
1271                        byRef: false
1272                        unpack: false
1273                    )
1274                )
1275            )
1276        )
1277    )
1278    2: Stmt_Expression(
1279        expr: Expr_Assign(
1280            var: Expr_Variable(
1281                name: array
1282            )
1283            expr: Expr_Array(
1284                items: array(
1285                    0: ArrayItem(
1286                        key: Scalar_String(
1287                            value: key
1288                        )
1289                        value: Expr_Variable(
1290                            name: value
1291                        )
1292                        byRef: false
1293                        unpack: false
1294                    )
1295                    1: ArrayItem(
1296                        key: null
1297                        value: Expr_Variable(
1298                            name: oopsAnotherValue
1299                        )
1300                        byRef: false
1301                        unpack: false
1302                    )
1303                )
1304            )
1305        )
1306    )
1307)
1308-----
1309<?php
1310function foo() :
1311{
1312    return $a;
1313}
1314-----
1315Syntax error, unexpected '{' from 3:1 to 3:1
1316array(
1317    0: Stmt_Function(
1318        attrGroups: array(
1319        )
1320        byRef: false
1321        name: Identifier(
1322            name: foo
1323        )
1324        params: array(
1325        )
1326        returnType: null
1327        stmts: array(
1328            0: Stmt_Return(
1329                expr: Expr_Variable(
1330                    name: a
1331                )
1332            )
1333        )
1334    )
1335)
1336-----
1337<?php
1338$a = ["a "thing"];
1339-----
1340Syntax error, unexpected T_STRING, expecting ',' or ']' or ')' from 2:11 to 2:15
1341-----
1342<?php
1343class A {
1344    /** @var ?string */
1345    private $foo
1346
1347    public function __construct(string $s) {
1348        $this->foo = $s;
1349    }
1350}
1351class B {
1352    const X = 1
1353}
1354-----
1355Syntax error, unexpected T_PUBLIC, expecting ';' from 6:5 to 6:10
1356Syntax error, unexpected '}', expecting ';' from 12:1 to 12:1
1357array(
1358    0: Stmt_Class(
1359        attrGroups: array(
1360        )
1361        flags: 0
1362        name: Identifier(
1363            name: A
1364        )
1365        extends: null
1366        implements: array(
1367        )
1368        stmts: array(
1369            0: Stmt_Property(
1370                attrGroups: array(
1371                )
1372                flags: PRIVATE (4)
1373                type: null
1374                props: array(
1375                    0: PropertyItem(
1376                        name: VarLikeIdentifier(
1377                            name: foo
1378                        )
1379                        default: null
1380                    )
1381                )
1382                comments: array(
1383                    0: /** @var ?string */
1384                )
1385            )
1386            1: Stmt_ClassMethod(
1387                attrGroups: array(
1388                )
1389                flags: PUBLIC (1)
1390                byRef: false
1391                name: Identifier(
1392                    name: __construct
1393                )
1394                params: array(
1395                    0: Param(
1396                        attrGroups: array(
1397                        )
1398                        flags: 0
1399                        type: Identifier(
1400                            name: string
1401                        )
1402                        byRef: false
1403                        variadic: false
1404                        var: Expr_Variable(
1405                            name: s
1406                        )
1407                        default: null
1408                    )
1409                )
1410                returnType: null
1411                stmts: array(
1412                    0: Stmt_Expression(
1413                        expr: Expr_Assign(
1414                            var: Expr_PropertyFetch(
1415                                var: Expr_Variable(
1416                                    name: this
1417                                )
1418                                name: Identifier(
1419                                    name: foo
1420                                )
1421                            )
1422                            expr: Expr_Variable(
1423                                name: s
1424                            )
1425                        )
1426                    )
1427                )
1428            )
1429        )
1430    )
1431    1: Stmt_Class(
1432        attrGroups: array(
1433        )
1434        flags: 0
1435        name: Identifier(
1436            name: B
1437        )
1438        extends: null
1439        implements: array(
1440        )
1441        stmts: array(
1442            0: Stmt_ClassConst(
1443                attrGroups: array(
1444                )
1445                flags: 0
1446                type: null
1447                consts: array(
1448                    0: Const(
1449                        name: Identifier(
1450                            name: X
1451                        )
1452                        value: Scalar_Int(
1453                            value: 1
1454                        )
1455                    )
1456                )
1457            )
1458        )
1459    )
1460)
1461