Security update for Core, with self-updated composer
[yaffs-website] / vendor / nikic / php-parser / test / code / parser / semiReserved.test
1 Valid usages of reserved keywords as identifiers
2 -----
3 <?php
4
5 class Test {
6     function array() {}
7     function public() {}
8
9     static function list() {}
10     static function protected() {}
11
12     public $class;
13     public $private;
14
15     const TRAIT = 3, FINAL = 4;
16
17     const __CLASS__ = 1, __TRAIT__ = 2, __FUNCTION__ = 3, __METHOD__ = 4, __LINE__ = 5,
18           __FILE__ = 6, __DIR__ = 7, __NAMESPACE__ = 8;
19     // __halt_compiler does not work
20 }
21
22 $t = new Test;
23 $t->array();
24 $t->public();
25
26 Test::list();
27 Test::protected();
28
29 $t->class;
30 $t->private;
31
32 Test::TRAIT;
33 Test::FINAL;
34
35 class Foo {
36     use TraitA, TraitB {
37         TraitA::catch insteadof namespace\TraitB;
38         TraitA::list as foreach;
39         TraitB::throw as protected public;
40         TraitB::self as protected;
41         exit as die;
42         \TraitC::exit as bye;
43         namespace\TraitC::exit as byebye;
44         TraitA::
45             //
46             /** doc comment */
47             #
48         catch /* comment */
49             // comment
50             # comment
51         insteadof TraitB;
52     }
53 }
54 -----
55 array(
56     0: Stmt_Class(
57         flags: 0
58         name: Test
59         extends: null
60         implements: array(
61         )
62         stmts: array(
63             0: Stmt_ClassMethod(
64                 flags: 0
65                 byRef: false
66                 name: array
67                 params: array(
68                 )
69                 returnType: null
70                 stmts: array(
71                 )
72             )
73             1: Stmt_ClassMethod(
74                 flags: 0
75                 byRef: false
76                 name: public
77                 params: array(
78                 )
79                 returnType: null
80                 stmts: array(
81                 )
82             )
83             2: Stmt_ClassMethod(
84                 flags: MODIFIER_STATIC (8)
85                 byRef: false
86                 name: list
87                 params: array(
88                 )
89                 returnType: null
90                 stmts: array(
91                 )
92             )
93             3: Stmt_ClassMethod(
94                 flags: MODIFIER_STATIC (8)
95                 byRef: false
96                 name: protected
97                 params: array(
98                 )
99                 returnType: null
100                 stmts: array(
101                 )
102             )
103             4: Stmt_Property(
104                 flags: MODIFIER_PUBLIC (1)
105                 props: array(
106                     0: Stmt_PropertyProperty(
107                         name: class
108                         default: null
109                     )
110                 )
111             )
112             5: Stmt_Property(
113                 flags: MODIFIER_PUBLIC (1)
114                 props: array(
115                     0: Stmt_PropertyProperty(
116                         name: private
117                         default: null
118                     )
119                 )
120             )
121             6: Stmt_ClassConst(
122                 flags: 0
123                 consts: array(
124                     0: Const(
125                         name: TRAIT
126                         value: Scalar_LNumber(
127                             value: 3
128                         )
129                     )
130                     1: Const(
131                         name: FINAL
132                         value: Scalar_LNumber(
133                             value: 4
134                         )
135                     )
136                 )
137             )
138             7: Stmt_ClassConst(
139                 flags: 0
140                 consts: array(
141                     0: Const(
142                         name: __CLASS__
143                         value: Scalar_LNumber(
144                             value: 1
145                         )
146                     )
147                     1: Const(
148                         name: __TRAIT__
149                         value: Scalar_LNumber(
150                             value: 2
151                         )
152                     )
153                     2: Const(
154                         name: __FUNCTION__
155                         value: Scalar_LNumber(
156                             value: 3
157                         )
158                     )
159                     3: Const(
160                         name: __METHOD__
161                         value: Scalar_LNumber(
162                             value: 4
163                         )
164                     )
165                     4: Const(
166                         name: __LINE__
167                         value: Scalar_LNumber(
168                             value: 5
169                         )
170                     )
171                     5: Const(
172                         name: __FILE__
173                         value: Scalar_LNumber(
174                             value: 6
175                         )
176                     )
177                     6: Const(
178                         name: __DIR__
179                         value: Scalar_LNumber(
180                             value: 7
181                         )
182                     )
183                     7: Const(
184                         name: __NAMESPACE__
185                         value: Scalar_LNumber(
186                             value: 8
187                         )
188                     )
189                 )
190             )
191         )
192     )
193     1: Expr_Assign(
194         var: Expr_Variable(
195             name: t
196         )
197         expr: Expr_New(
198             class: Name(
199                 parts: array(
200                     0: Test
201                 )
202             )
203             args: array(
204             )
205         )
206     )
207     2: Expr_MethodCall(
208         var: Expr_Variable(
209             name: t
210         )
211         name: array
212         args: array(
213         )
214     )
215     3: Expr_MethodCall(
216         var: Expr_Variable(
217             name: t
218         )
219         name: public
220         args: array(
221         )
222     )
223     4: Expr_StaticCall(
224         class: Name(
225             parts: array(
226                 0: Test
227             )
228         )
229         name: list
230         args: array(
231         )
232     )
233     5: Expr_StaticCall(
234         class: Name(
235             parts: array(
236                 0: Test
237             )
238         )
239         name: protected
240         args: array(
241         )
242     )
243     6: Expr_PropertyFetch(
244         var: Expr_Variable(
245             name: t
246         )
247         name: class
248     )
249     7: Expr_PropertyFetch(
250         var: Expr_Variable(
251             name: t
252         )
253         name: private
254     )
255     8: Expr_ClassConstFetch(
256         class: Name(
257             parts: array(
258                 0: Test
259             )
260         )
261         name: TRAIT
262     )
263     9: Expr_ClassConstFetch(
264         class: Name(
265             parts: array(
266                 0: Test
267             )
268         )
269         name: FINAL
270     )
271     10: Stmt_Class(
272         flags: 0
273         name: Foo
274         extends: null
275         implements: array(
276         )
277         stmts: array(
278             0: Stmt_TraitUse(
279                 traits: array(
280                     0: Name(
281                         parts: array(
282                             0: TraitA
283                         )
284                     )
285                     1: Name(
286                         parts: array(
287                             0: TraitB
288                         )
289                     )
290                 )
291                 adaptations: array(
292                     0: Stmt_TraitUseAdaptation_Precedence(
293                         trait: Name(
294                             parts: array(
295                                 0: TraitA
296                             )
297                         )
298                         method: catch
299                         insteadof: array(
300                             0: Name_Relative(
301                                 parts: array(
302                                     0: TraitB
303                                 )
304                             )
305                         )
306                     )
307                     1: Stmt_TraitUseAdaptation_Alias(
308                         trait: Name(
309                             parts: array(
310                                 0: TraitA
311                             )
312                         )
313                         method: list
314                         newModifier: null
315                         newName: foreach
316                     )
317                     2: Stmt_TraitUseAdaptation_Alias(
318                         trait: Name(
319                             parts: array(
320                                 0: TraitB
321                             )
322                         )
323                         method: throw
324                         newModifier: MODIFIER_PROTECTED (2)
325                         newName: public
326                     )
327                     3: Stmt_TraitUseAdaptation_Alias(
328                         trait: Name(
329                             parts: array(
330                                 0: TraitB
331                             )
332                         )
333                         method: self
334                         newModifier: MODIFIER_PROTECTED (2)
335                         newName: null
336                     )
337                     4: Stmt_TraitUseAdaptation_Alias(
338                         trait: null
339                         method: exit
340                         newModifier: null
341                         newName: die
342                     )
343                     5: Stmt_TraitUseAdaptation_Alias(
344                         trait: Name_FullyQualified(
345                             parts: array(
346                                 0: TraitC
347                             )
348                         )
349                         method: exit
350                         newModifier: null
351                         newName: bye
352                     )
353                     6: Stmt_TraitUseAdaptation_Alias(
354                         trait: Name_Relative(
355                             parts: array(
356                                 0: TraitC
357                             )
358                         )
359                         method: exit
360                         newModifier: null
361                         newName: byebye
362                     )
363                     7: Stmt_TraitUseAdaptation_Precedence(
364                         trait: Name(
365                             parts: array(
366                                 0: TraitA
367                             )
368                         )
369                         method: catch
370                         insteadof: array(
371                             0: Name(
372                                 parts: array(
373                                     0: TraitB
374                                 )
375                             )
376                         )
377                     )
378                 )
379             )
380         )
381     )
382 )