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