xref: /PHP-Parser/test/code/parser/expr/newDeref.test (revision beba9c52)
1New dereference without parentheses
2-----
3<?php
4
5new A()->foo;
6new A()->foo();
7new A()::FOO;
8new A()::foo();
9new A()::$foo;
10new A()[0];
11new A()();
12
13new class {}->foo;
14new class {}->foo();
15new class {}::FOO;
16new class {}::foo();
17new class {}::$foo;
18new class {}[0];
19new class {}();
20-----
21array(
22    0: Stmt_Expression(
23        expr: Expr_PropertyFetch(
24            var: Expr_New(
25                class: Name(
26                    name: A
27                )
28                args: array(
29                )
30            )
31            name: Identifier(
32                name: foo
33            )
34        )
35    )
36    1: Stmt_Expression(
37        expr: Expr_MethodCall(
38            var: Expr_New(
39                class: Name(
40                    name: A
41                )
42                args: array(
43                )
44            )
45            name: Identifier(
46                name: foo
47            )
48            args: array(
49            )
50        )
51    )
52    2: Stmt_Expression(
53        expr: Expr_ClassConstFetch(
54            class: Expr_New(
55                class: Name(
56                    name: A
57                )
58                args: array(
59                )
60            )
61            name: Identifier(
62                name: FOO
63            )
64        )
65    )
66    3: Stmt_Expression(
67        expr: Expr_StaticCall(
68            class: Expr_New(
69                class: Name(
70                    name: A
71                )
72                args: array(
73                )
74            )
75            name: Identifier(
76                name: foo
77            )
78            args: array(
79            )
80        )
81    )
82    4: Stmt_Expression(
83        expr: Expr_StaticPropertyFetch(
84            class: Expr_New(
85                class: Name(
86                    name: A
87                )
88                args: array(
89                )
90            )
91            name: VarLikeIdentifier(
92                name: foo
93            )
94        )
95    )
96    5: Stmt_Expression(
97        expr: Expr_ArrayDimFetch(
98            var: Expr_New(
99                class: Name(
100                    name: A
101                )
102                args: array(
103                )
104            )
105            dim: Scalar_Int(
106                value: 0
107            )
108        )
109    )
110    6: Stmt_Expression(
111        expr: Expr_FuncCall(
112            name: Expr_New(
113                class: Name(
114                    name: A
115                )
116                args: array(
117                )
118            )
119            args: array(
120            )
121        )
122    )
123    7: Stmt_Expression(
124        expr: Expr_PropertyFetch(
125            var: Expr_New(
126                class: Stmt_Class(
127                    attrGroups: array(
128                    )
129                    flags: 0
130                    name: null
131                    extends: null
132                    implements: array(
133                    )
134                    stmts: array(
135                    )
136                )
137                args: array(
138                )
139            )
140            name: Identifier(
141                name: foo
142            )
143        )
144    )
145    8: Stmt_Expression(
146        expr: Expr_MethodCall(
147            var: Expr_New(
148                class: Stmt_Class(
149                    attrGroups: array(
150                    )
151                    flags: 0
152                    name: null
153                    extends: null
154                    implements: array(
155                    )
156                    stmts: array(
157                    )
158                )
159                args: array(
160                )
161            )
162            name: Identifier(
163                name: foo
164            )
165            args: array(
166            )
167        )
168    )
169    9: Stmt_Expression(
170        expr: Expr_ClassConstFetch(
171            class: Expr_New(
172                class: Stmt_Class(
173                    attrGroups: array(
174                    )
175                    flags: 0
176                    name: null
177                    extends: null
178                    implements: array(
179                    )
180                    stmts: array(
181                    )
182                )
183                args: array(
184                )
185            )
186            name: Identifier(
187                name: FOO
188            )
189        )
190    )
191    10: Stmt_Expression(
192        expr: Expr_StaticCall(
193            class: Expr_New(
194                class: Stmt_Class(
195                    attrGroups: array(
196                    )
197                    flags: 0
198                    name: null
199                    extends: null
200                    implements: array(
201                    )
202                    stmts: array(
203                    )
204                )
205                args: array(
206                )
207            )
208            name: Identifier(
209                name: foo
210            )
211            args: array(
212            )
213        )
214    )
215    11: Stmt_Expression(
216        expr: Expr_StaticPropertyFetch(
217            class: Expr_New(
218                class: Stmt_Class(
219                    attrGroups: array(
220                    )
221                    flags: 0
222                    name: null
223                    extends: null
224                    implements: array(
225                    )
226                    stmts: array(
227                    )
228                )
229                args: array(
230                )
231            )
232            name: VarLikeIdentifier(
233                name: foo
234            )
235        )
236    )
237    12: Stmt_Expression(
238        expr: Expr_ArrayDimFetch(
239            var: Expr_New(
240                class: Stmt_Class(
241                    attrGroups: array(
242                    )
243                    flags: 0
244                    name: null
245                    extends: null
246                    implements: array(
247                    )
248                    stmts: array(
249                    )
250                )
251                args: array(
252                )
253            )
254            dim: Scalar_Int(
255                value: 0
256            )
257        )
258    )
259    13: Stmt_Expression(
260        expr: Expr_FuncCall(
261            name: Expr_New(
262                class: Stmt_Class(
263                    attrGroups: array(
264                    )
265                    flags: 0
266                    name: null
267                    extends: null
268                    implements: array(
269                    )
270                    stmts: array(
271                    )
272                )
273                args: array(
274                )
275            )
276            args: array(
277            )
278        )
279    )
280)
281