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                hooks: array(
718                )
719            )
720        )
721    )
722    5: Stmt_Interface(
723        attrGroups: array(
724        )
725        name: Identifier(
726            name: I
727        )
728        extends: array(
729            0: Name(
730                name: J
731            )
732        )
733        stmts: array(
734        )
735    )
736    6: Stmt_Unset(
737        vars: array(
738            0: Expr_Variable(
739                name: x
740            )
741        )
742    )
743    7: Stmt_Expression(
744        expr: Expr_Isset(
745            vars: array(
746                0: Expr_Variable(
747                    name: x
748                )
749            )
750        )
751    )
752    8: Stmt_Declare(
753        declares: array(
754            0: DeclareItem(
755                key: Identifier(
756                    name: a
757                )
758                value: Scalar_Int(
759                    value: 42
760                )
761            )
762        )
763        stmts: null
764    )
765    9: Stmt_Global(
766        vars: array(
767            0: Expr_Variable(
768                name: a
769            )
770        )
771    )
772    10: Stmt_Static(
773        vars: array(
774            0: StaticVar(
775                var: Expr_Variable(
776                    name: a
777                )
778                default: null
779            )
780        )
781    )
782    11: Stmt_Echo(
783        exprs: array(
784            0: Expr_Variable(
785                name: a
786            )
787        )
788    )
789    12: Stmt_For(
790        init: array(
791            0: Expr_Variable(
792                name: a
793            )
794        )
795        cond: array(
796            0: Expr_Variable(
797                name: b
798            )
799        )
800        loop: array(
801            0: Expr_Variable(
802                name: c
803            )
804        )
805        stmts: array(
806        )
807    )
808)
809-----
810<?php
811
812foo(Bar::);
813-----
814!!positions
815Syntax error, unexpected ')' from 3:10 to 3:10
816array(
817    0: Stmt_Expression[3:1 - 3:11](
818        expr: Expr_FuncCall[3:1 - 3:10](
819            name: Name[3:1 - 3:3](
820                name: foo
821            )
822            args: array(
823                0: Arg[3:5 - 3:9](
824                    name: null
825                    value: Expr_ClassConstFetch[3:5 - 3:9](
826                        class: Name[3:5 - 3:7](
827                            name: Bar
828                        )
829                        name: Expr_Error[3:10 - 3:9](
830                        )
831                    )
832                    byRef: false
833                    unpack: false
834                )
835            )
836        )
837    )
838)
839-----
840<?php
841
842class Foo {
843    public $bar1;
844    publi $foo;
845    public $bar;
846}
847-----
848Syntax error, unexpected T_STRING from 5:5 to 5:9
849array(
850    0: Stmt_Class(
851        attrGroups: array(
852        )
853        flags: 0
854        name: Identifier(
855            name: Foo
856        )
857        extends: null
858        implements: array(
859        )
860        stmts: array(
861            0: Stmt_Property(
862                attrGroups: array(
863                )
864                flags: PUBLIC (1)
865                type: null
866                props: array(
867                    0: PropertyItem(
868                        name: VarLikeIdentifier(
869                            name: bar1
870                        )
871                        default: null
872                    )
873                )
874                hooks: array(
875                )
876            )
877            1: Stmt_Property(
878                attrGroups: array(
879                )
880                flags: PUBLIC (1)
881                type: null
882                props: array(
883                    0: PropertyItem(
884                        name: VarLikeIdentifier(
885                            name: bar
886                        )
887                        default: null
888                    )
889                )
890                hooks: array(
891                )
892            )
893        )
894    )
895)
896-----
897<?php
898
899foreach ($foo) { $bar; }
900foreach ($foo as ) { $bar; }
901-----
902Syntax error, unexpected ')' from 3:14 to 3:14
903Syntax error, unexpected ')' from 4:18 to 4:18
904array(
905    0: Stmt_Foreach(
906        expr: Expr_Variable(
907            name: foo
908        )
909        keyVar: null
910        byRef: false
911        valueVar: Expr_Error(
912        )
913        stmts: array(
914            0: Stmt_Expression(
915                expr: Expr_Variable(
916                    name: bar
917                )
918            )
919        )
920    )
921    1: Stmt_Foreach(
922        expr: Expr_Variable(
923            name: foo
924        )
925        keyVar: null
926        byRef: false
927        valueVar: Expr_Error(
928        )
929        stmts: array(
930            0: Stmt_Expression(
931                expr: Expr_Variable(
932                    name: bar
933                )
934            )
935        )
936    )
937)
938-----
939<?php
940
941function foo(Type) {
942    $foo;
943}
944
945function foo(Type1 $foo, Type2) {
946    $bar;
947}
948
949function foo(...) {
950    $baz;
951}
952
953function foo(&) {
954    $qux;
955}
956
957function foo(Bar)
958
959class Bar {
960    function foo(Baz)
961}
962
963function(Foo);
964-----
965Syntax error, unexpected ')', expecting T_VARIABLE from 3:18 to 3:18
966Syntax error, unexpected ')', expecting T_VARIABLE from 7:31 to 7:31
967Syntax error, unexpected ')', expecting T_VARIABLE from 11:17 to 11:17
968Syntax error, unexpected T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG, expecting T_VARIABLE from 15:14 to 15:14
969Syntax error, unexpected ')', expecting T_VARIABLE from 19:17 to 19:17
970Syntax error, unexpected ')', expecting T_VARIABLE from 22:21 to 22:21
971Syntax error, unexpected ')', expecting T_VARIABLE from 25:13 to 25:13
972array(
973    0: Stmt_Function(
974        attrGroups: array(
975        )
976        byRef: false
977        name: Identifier(
978            name: foo
979        )
980        params: array(
981            0: Param(
982                attrGroups: array(
983                )
984                flags: 0
985                type: Name(
986                    name: Type
987                )
988                byRef: false
989                variadic: false
990                var: Expr_Error(
991                )
992                default: null
993                hooks: array(
994                )
995            )
996        )
997        returnType: null
998        stmts: array(
999            0: Stmt_Expression(
1000                expr: Expr_Variable(
1001                    name: foo
1002                )
1003            )
1004        )
1005    )
1006    1: Stmt_Function(
1007        attrGroups: array(
1008        )
1009        byRef: false
1010        name: Identifier(
1011            name: foo
1012        )
1013        params: array(
1014            0: Param(
1015                attrGroups: array(
1016                )
1017                flags: 0
1018                type: Name(
1019                    name: Type1
1020                )
1021                byRef: false
1022                variadic: false
1023                var: Expr_Variable(
1024                    name: foo
1025                )
1026                default: null
1027                hooks: array(
1028                )
1029            )
1030            1: Param(
1031                attrGroups: array(
1032                )
1033                flags: 0
1034                type: Name(
1035                    name: Type2
1036                )
1037                byRef: false
1038                variadic: false
1039                var: Expr_Error(
1040                )
1041                default: null
1042                hooks: array(
1043                )
1044            )
1045        )
1046        returnType: null
1047        stmts: array(
1048            0: Stmt_Expression(
1049                expr: Expr_Variable(
1050                    name: bar
1051                )
1052            )
1053        )
1054    )
1055    2: Stmt_Function(
1056        attrGroups: array(
1057        )
1058        byRef: false
1059        name: Identifier(
1060            name: foo
1061        )
1062        params: array(
1063            0: Param(
1064                attrGroups: array(
1065                )
1066                flags: 0
1067                type: null
1068                byRef: false
1069                variadic: true
1070                var: Expr_Error(
1071                )
1072                default: null
1073                hooks: array(
1074                )
1075            )
1076        )
1077        returnType: null
1078        stmts: array(
1079            0: Stmt_Expression(
1080                expr: Expr_Variable(
1081                    name: baz
1082                )
1083            )
1084        )
1085    )
1086    3: Stmt_Function(
1087        attrGroups: array(
1088        )
1089        byRef: false
1090        name: Identifier(
1091            name: foo
1092        )
1093        params: array(
1094            0: Param(
1095                attrGroups: array(
1096                )
1097                flags: 0
1098                type: null
1099                byRef: false
1100                variadic: false
1101                var: Expr_Error(
1102                )
1103                default: null
1104                hooks: array(
1105                )
1106            )
1107        )
1108        returnType: null
1109        stmts: array(
1110            0: Stmt_Expression(
1111                expr: Expr_Variable(
1112                    name: qux
1113                )
1114            )
1115        )
1116    )
1117    4: Stmt_Function(
1118        attrGroups: array(
1119        )
1120        byRef: false
1121        name: Identifier(
1122            name: foo
1123        )
1124        params: array(
1125            0: Param(
1126                attrGroups: array(
1127                )
1128                flags: 0
1129                type: Name(
1130                    name: Bar
1131                )
1132                byRef: false
1133                variadic: false
1134                var: Expr_Error(
1135                )
1136                default: null
1137                hooks: array(
1138                )
1139            )
1140        )
1141        returnType: null
1142        stmts: array(
1143        )
1144    )
1145    5: Stmt_Class(
1146        attrGroups: array(
1147        )
1148        flags: 0
1149        name: Identifier(
1150            name: Bar
1151        )
1152        extends: null
1153        implements: array(
1154        )
1155        stmts: array(
1156            0: Stmt_ClassMethod(
1157                attrGroups: array(
1158                )
1159                flags: 0
1160                byRef: false
1161                name: Identifier(
1162                    name: foo
1163                )
1164                params: array(
1165                    0: Param(
1166                        attrGroups: array(
1167                        )
1168                        flags: 0
1169                        type: Name(
1170                            name: Baz
1171                        )
1172                        byRef: false
1173                        variadic: false
1174                        var: Expr_Error(
1175                        )
1176                        default: null
1177                        hooks: array(
1178                        )
1179                    )
1180                )
1181                returnType: null
1182                stmts: array(
1183                )
1184            )
1185        )
1186    )
1187    6: Stmt_Expression(
1188        expr: Expr_Closure(
1189            attrGroups: array(
1190            )
1191            static: false
1192            byRef: false
1193            params: array(
1194                0: Param(
1195                    attrGroups: array(
1196                    )
1197                    flags: 0
1198                    type: Name(
1199                        name: Foo
1200                    )
1201                    byRef: false
1202                    variadic: false
1203                    var: Expr_Error(
1204                    )
1205                    default: null
1206                    hooks: array(
1207                    )
1208                )
1209            )
1210            uses: array(
1211            )
1212            returnType: null
1213            stmts: array(
1214            )
1215        )
1216    )
1217)
1218-----
1219<?php
1220$array = [
1221    $this->value $oopsAnotherValue->get()
1222];
1223$array = [
1224    $value $oopsAnotherValue
1225];
1226$array = [
1227    'key' => $value $oopsAnotherValue
1228];
1229-----
1230Syntax error, unexpected T_VARIABLE, expecting ',' or ']' or ')' from 3:18 to 3:34
1231Syntax error, unexpected T_VARIABLE, expecting ',' or ']' or ')' from 6:12 to 6:28
1232Syntax error, unexpected T_VARIABLE, expecting ',' or ']' or ')' from 9:21 to 9:37
1233array(
1234    0: Stmt_Expression(
1235        expr: Expr_Assign(
1236            var: Expr_Variable(
1237                name: array
1238            )
1239            expr: Expr_Array(
1240                items: array(
1241                    0: ArrayItem(
1242                        key: null
1243                        value: Expr_PropertyFetch(
1244                            var: Expr_Variable(
1245                                name: this
1246                            )
1247                            name: Identifier(
1248                                name: value
1249                            )
1250                        )
1251                        byRef: false
1252                        unpack: false
1253                    )
1254                    1: ArrayItem(
1255                        key: null
1256                        value: Expr_MethodCall(
1257                            var: Expr_Variable(
1258                                name: oopsAnotherValue
1259                            )
1260                            name: Identifier(
1261                                name: get
1262                            )
1263                            args: array(
1264                            )
1265                        )
1266                        byRef: false
1267                        unpack: false
1268                    )
1269                )
1270            )
1271        )
1272    )
1273    1: Stmt_Expression(
1274        expr: Expr_Assign(
1275            var: Expr_Variable(
1276                name: array
1277            )
1278            expr: Expr_Array(
1279                items: array(
1280                    0: ArrayItem(
1281                        key: null
1282                        value: Expr_Variable(
1283                            name: value
1284                        )
1285                        byRef: false
1286                        unpack: false
1287                    )
1288                    1: ArrayItem(
1289                        key: null
1290                        value: Expr_Variable(
1291                            name: oopsAnotherValue
1292                        )
1293                        byRef: false
1294                        unpack: false
1295                    )
1296                )
1297            )
1298        )
1299    )
1300    2: Stmt_Expression(
1301        expr: Expr_Assign(
1302            var: Expr_Variable(
1303                name: array
1304            )
1305            expr: Expr_Array(
1306                items: array(
1307                    0: ArrayItem(
1308                        key: Scalar_String(
1309                            value: key
1310                        )
1311                        value: Expr_Variable(
1312                            name: value
1313                        )
1314                        byRef: false
1315                        unpack: false
1316                    )
1317                    1: ArrayItem(
1318                        key: null
1319                        value: Expr_Variable(
1320                            name: oopsAnotherValue
1321                        )
1322                        byRef: false
1323                        unpack: false
1324                    )
1325                )
1326            )
1327        )
1328    )
1329)
1330-----
1331<?php
1332function foo() :
1333{
1334    return $a;
1335}
1336-----
1337Syntax error, unexpected '{' from 3:1 to 3:1
1338array(
1339    0: Stmt_Function(
1340        attrGroups: array(
1341        )
1342        byRef: false
1343        name: Identifier(
1344            name: foo
1345        )
1346        params: array(
1347        )
1348        returnType: null
1349        stmts: array(
1350            0: Stmt_Return(
1351                expr: Expr_Variable(
1352                    name: a
1353                )
1354            )
1355        )
1356    )
1357)
1358-----
1359<?php
1360$a = ["a "thing"];
1361-----
1362Syntax error, unexpected T_STRING, expecting ',' or ']' or ')' from 2:11 to 2:15
1363-----
1364<?php
1365class A {
1366    /** @var ?string */
1367    private $foo
1368
1369    public function __construct(string $s) {
1370        $this->foo = $s;
1371    }
1372}
1373class B {
1374    const X = 1
1375}
1376-----
1377Syntax error, unexpected T_PUBLIC, expecting ';' or '{' from 6:5 to 6:10
1378Syntax error, unexpected '}', expecting ';' from 12:1 to 12:1
1379array(
1380    0: Stmt_Class(
1381        attrGroups: array(
1382        )
1383        flags: 0
1384        name: Identifier(
1385            name: A
1386        )
1387        extends: null
1388        implements: array(
1389        )
1390        stmts: array(
1391            0: Stmt_Property(
1392                attrGroups: array(
1393                )
1394                flags: PRIVATE (4)
1395                type: null
1396                props: array(
1397                    0: PropertyItem(
1398                        name: VarLikeIdentifier(
1399                            name: foo
1400                        )
1401                        default: null
1402                    )
1403                )
1404                hooks: array(
1405                )
1406                comments: array(
1407                    0: /** @var ?string */
1408                )
1409            )
1410            1: Stmt_ClassMethod(
1411                attrGroups: array(
1412                )
1413                flags: PUBLIC (1)
1414                byRef: false
1415                name: Identifier(
1416                    name: __construct
1417                )
1418                params: array(
1419                    0: Param(
1420                        attrGroups: array(
1421                        )
1422                        flags: 0
1423                        type: Identifier(
1424                            name: string
1425                        )
1426                        byRef: false
1427                        variadic: false
1428                        var: Expr_Variable(
1429                            name: s
1430                        )
1431                        default: null
1432                        hooks: array(
1433                        )
1434                    )
1435                )
1436                returnType: null
1437                stmts: array(
1438                    0: Stmt_Expression(
1439                        expr: Expr_Assign(
1440                            var: Expr_PropertyFetch(
1441                                var: Expr_Variable(
1442                                    name: this
1443                                )
1444                                name: Identifier(
1445                                    name: foo
1446                                )
1447                            )
1448                            expr: Expr_Variable(
1449                                name: s
1450                            )
1451                        )
1452                    )
1453                )
1454            )
1455        )
1456    )
1457    1: Stmt_Class(
1458        attrGroups: array(
1459        )
1460        flags: 0
1461        name: Identifier(
1462            name: B
1463        )
1464        extends: null
1465        implements: array(
1466        )
1467        stmts: array(
1468            0: Stmt_ClassConst(
1469                attrGroups: array(
1470                )
1471                flags: 0
1472                type: null
1473                consts: array(
1474                    0: Const(
1475                        name: Identifier(
1476                            name: X
1477                        )
1478                        value: Scalar_Int(
1479                            value: 1
1480                        )
1481                    )
1482                )
1483            )
1484        )
1485    )
1486)
1487