@ant-yasa/uast-parser-php 0.2.9 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/package.json +1 -1
  2. package/package.json +1 -1
  3. package/src/index.ts +26 -0
  4. package/src/parser.ts +1234 -0
  5. package/tests/benchmark/base/advanced.php +20 -0
  6. package/tests/benchmark/base/advanced.php.json +1269 -0
  7. package/tests/benchmark/base/basic.php +3 -0
  8. package/tests/benchmark/base/basic.php.json +292 -0
  9. package/tests/benchmark/base/closure-class.php +24 -0
  10. package/tests/benchmark/base/closure-class.php.json +1623 -0
  11. package/tests/benchmark/base/control-flow.php +37 -0
  12. package/tests/benchmark/base/control-flow.php.json +2010 -0
  13. package/tests/benchmark/base/enum-trait-adapt.php +31 -0
  14. package/tests/benchmark/base/enum-trait-adapt.php.json +965 -0
  15. package/tests/benchmark/base/exprs.php +4 -0
  16. package/tests/benchmark/base/exprs.php.json +811 -0
  17. package/tests/benchmark/base/flow-extras.php +12 -0
  18. package/tests/benchmark/base/flow-extras.php.json +897 -0
  19. package/tests/benchmark/base/function.php +7 -0
  20. package/tests/benchmark/base/function.php.json +536 -0
  21. package/tests/benchmark/base/modern-php.php +13 -0
  22. package/tests/benchmark/base/modern-php.php.json +508 -0
  23. package/tests/benchmark/base/namespace.php +5 -0
  24. package/tests/benchmark/base/namespace.php.json +307 -0
  25. package/tests/benchmark/base/new-static.php +3 -0
  26. package/tests/benchmark/base/new-static.php.json +399 -0
  27. package/tests/benchmark/base/runtime.php +13 -0
  28. package/tests/benchmark/base/runtime.php.json +1095 -0
  29. package/tests/benchmark/base/strings-casts.php +17 -0
  30. package/tests/benchmark/base/strings-casts.php.json +1357 -0
  31. package/tests/benchmark/base/structures.php +26 -0
  32. package/tests/benchmark/base/structures.php.json +1582 -0
  33. package/tests/index.ts +87 -0
@@ -0,0 +1,307 @@
1
+ {
2
+ "type": "CompileUnit",
3
+ "body": [
4
+ {
5
+ "type": "PackageDeclaration",
6
+ "packageName": {
7
+ "type": "Identifier",
8
+ "name": "Foo\\Bar",
9
+ "_meta": {}
10
+ },
11
+ "_meta": {
12
+ "loc": {
13
+ "start": {
14
+ "line": 2,
15
+ "column": 11
16
+ },
17
+ "end": {
18
+ "line": 2,
19
+ "column": 18
20
+ },
21
+ "sourcefile": "namespace.php"
22
+ }
23
+ },
24
+ "loc": {
25
+ "start": {
26
+ "line": 2,
27
+ "column": 11
28
+ },
29
+ "end": {
30
+ "line": 2,
31
+ "column": 18
32
+ },
33
+ "sourcefile": "namespace.php"
34
+ }
35
+ },
36
+ {
37
+ "type": "ExpressionStatement",
38
+ "expression": {
39
+ "type": "ImportExpression",
40
+ "from": {
41
+ "type": "Literal",
42
+ "value": "Baz\\Qux",
43
+ "literalType": "string",
44
+ "_meta": {}
45
+ },
46
+ "local": {
47
+ "type": "Identifier",
48
+ "name": "Q",
49
+ "_meta": {
50
+ "loc": {
51
+ "start": {
52
+ "line": 3,
53
+ "column": 16
54
+ },
55
+ "end": {
56
+ "line": 3,
57
+ "column": 17
58
+ },
59
+ "sourcefile": "namespace.php"
60
+ }
61
+ },
62
+ "loc": {
63
+ "start": {
64
+ "line": 3,
65
+ "column": 16
66
+ },
67
+ "end": {
68
+ "line": 3,
69
+ "column": 17
70
+ },
71
+ "sourcefile": "namespace.php"
72
+ }
73
+ },
74
+ "imported": null,
75
+ "_meta": {
76
+ "loc": {
77
+ "start": {
78
+ "line": 3,
79
+ "column": 5
80
+ },
81
+ "end": {
82
+ "line": 3,
83
+ "column": 17
84
+ },
85
+ "sourcefile": "namespace.php"
86
+ }
87
+ },
88
+ "loc": {
89
+ "start": {
90
+ "line": 3,
91
+ "column": 5
92
+ },
93
+ "end": {
94
+ "line": 3,
95
+ "column": 17
96
+ },
97
+ "sourcefile": "namespace.php"
98
+ }
99
+ },
100
+ "_meta": {}
101
+ },
102
+ {
103
+ "type": "ExpressionStatement",
104
+ "expression": {
105
+ "type": "ImportExpression",
106
+ "from": {
107
+ "type": "Literal",
108
+ "value": "a.php",
109
+ "literalType": "string",
110
+ "_meta": {
111
+ "loc": {
112
+ "start": {
113
+ "line": 4,
114
+ "column": 9
115
+ },
116
+ "end": {
117
+ "line": 4,
118
+ "column": 16
119
+ },
120
+ "sourcefile": "namespace.php"
121
+ },
122
+ "encapsed": true
123
+ },
124
+ "loc": {
125
+ "start": {
126
+ "line": 4,
127
+ "column": 9
128
+ },
129
+ "end": {
130
+ "line": 4,
131
+ "column": 16
132
+ },
133
+ "sourcefile": "namespace.php"
134
+ }
135
+ },
136
+ "local": null,
137
+ "imported": null,
138
+ "_meta": {
139
+ "require": false,
140
+ "once": false,
141
+ "loc": {
142
+ "start": {
143
+ "line": 4,
144
+ "column": 1
145
+ },
146
+ "end": {
147
+ "line": 4,
148
+ "column": 16
149
+ },
150
+ "sourcefile": "namespace.php"
151
+ }
152
+ },
153
+ "loc": {
154
+ "start": {
155
+ "line": 4,
156
+ "column": 1
157
+ },
158
+ "end": {
159
+ "line": 4,
160
+ "column": 16
161
+ },
162
+ "sourcefile": "namespace.php"
163
+ }
164
+ },
165
+ "_meta": {
166
+ "loc": {
167
+ "start": {
168
+ "line": 4,
169
+ "column": 1
170
+ },
171
+ "end": {
172
+ "line": 4,
173
+ "column": 17
174
+ },
175
+ "sourcefile": "namespace.php"
176
+ }
177
+ },
178
+ "loc": {
179
+ "start": {
180
+ "line": 4,
181
+ "column": 1
182
+ },
183
+ "end": {
184
+ "line": 4,
185
+ "column": 17
186
+ },
187
+ "sourcefile": "namespace.php"
188
+ }
189
+ },
190
+ {
191
+ "type": "ExpressionStatement",
192
+ "expression": {
193
+ "type": "ImportExpression",
194
+ "from": {
195
+ "type": "Literal",
196
+ "value": "b.php",
197
+ "literalType": "string",
198
+ "_meta": {
199
+ "loc": {
200
+ "start": {
201
+ "line": 5,
202
+ "column": 14
203
+ },
204
+ "end": {
205
+ "line": 5,
206
+ "column": 21
207
+ },
208
+ "sourcefile": "namespace.php"
209
+ },
210
+ "encapsed": true
211
+ },
212
+ "loc": {
213
+ "start": {
214
+ "line": 5,
215
+ "column": 14
216
+ },
217
+ "end": {
218
+ "line": 5,
219
+ "column": 21
220
+ },
221
+ "sourcefile": "namespace.php"
222
+ }
223
+ },
224
+ "local": null,
225
+ "imported": null,
226
+ "_meta": {
227
+ "require": true,
228
+ "once": true,
229
+ "loc": {
230
+ "start": {
231
+ "line": 5,
232
+ "column": 1
233
+ },
234
+ "end": {
235
+ "line": 5,
236
+ "column": 21
237
+ },
238
+ "sourcefile": "namespace.php"
239
+ }
240
+ },
241
+ "loc": {
242
+ "start": {
243
+ "line": 5,
244
+ "column": 1
245
+ },
246
+ "end": {
247
+ "line": 5,
248
+ "column": 21
249
+ },
250
+ "sourcefile": "namespace.php"
251
+ }
252
+ },
253
+ "_meta": {
254
+ "loc": {
255
+ "start": {
256
+ "line": 5,
257
+ "column": 1
258
+ },
259
+ "end": {
260
+ "line": 5,
261
+ "column": 22
262
+ },
263
+ "sourcefile": "namespace.php"
264
+ }
265
+ },
266
+ "loc": {
267
+ "start": {
268
+ "line": 5,
269
+ "column": 1
270
+ },
271
+ "end": {
272
+ "line": 5,
273
+ "column": 22
274
+ },
275
+ "sourcefile": "namespace.php"
276
+ }
277
+ }
278
+ ],
279
+ "language": "php",
280
+ "languageVersion": null,
281
+ "uri": "namespace.php",
282
+ "version": "0.0.0",
283
+ "_meta": {
284
+ "loc": {
285
+ "start": {
286
+ "line": 1,
287
+ "column": 1
288
+ },
289
+ "end": {
290
+ "line": 6,
291
+ "column": 1
292
+ },
293
+ "sourcefile": "namespace.php"
294
+ }
295
+ },
296
+ "loc": {
297
+ "start": {
298
+ "line": 1,
299
+ "column": 1
300
+ },
301
+ "end": {
302
+ "line": 6,
303
+ "column": 1
304
+ },
305
+ "sourcefile": "namespace.php"
306
+ }
307
+ }
@@ -0,0 +1,3 @@
1
+ <?php
2
+ $obj = new User($id);
3
+ $v = Foo::bar($obj);
@@ -0,0 +1,399 @@
1
+ {
2
+ "type": "CompileUnit",
3
+ "body": [
4
+ {
5
+ "type": "ExpressionStatement",
6
+ "expression": {
7
+ "type": "AssignmentExpression",
8
+ "left": {
9
+ "type": "Identifier",
10
+ "name": "obj",
11
+ "_meta": {
12
+ "loc": {
13
+ "start": {
14
+ "line": 2,
15
+ "column": 1
16
+ },
17
+ "end": {
18
+ "line": 2,
19
+ "column": 5
20
+ },
21
+ "sourcefile": "new-static.php"
22
+ }
23
+ },
24
+ "loc": {
25
+ "start": {
26
+ "line": 2,
27
+ "column": 1
28
+ },
29
+ "end": {
30
+ "line": 2,
31
+ "column": 5
32
+ },
33
+ "sourcefile": "new-static.php"
34
+ }
35
+ },
36
+ "right": {
37
+ "type": "NewExpression",
38
+ "callee": {
39
+ "type": "Identifier",
40
+ "name": "User",
41
+ "_meta": {
42
+ "loc": {
43
+ "start": {
44
+ "line": 2,
45
+ "column": 12
46
+ },
47
+ "end": {
48
+ "line": 2,
49
+ "column": 16
50
+ },
51
+ "sourcefile": "new-static.php"
52
+ }
53
+ },
54
+ "loc": {
55
+ "start": {
56
+ "line": 2,
57
+ "column": 12
58
+ },
59
+ "end": {
60
+ "line": 2,
61
+ "column": 16
62
+ },
63
+ "sourcefile": "new-static.php"
64
+ }
65
+ },
66
+ "arguments": [],
67
+ "_meta": {
68
+ "loc": {
69
+ "start": {
70
+ "line": 2,
71
+ "column": 8
72
+ },
73
+ "end": {
74
+ "line": 2,
75
+ "column": 21
76
+ },
77
+ "sourcefile": "new-static.php"
78
+ }
79
+ },
80
+ "loc": {
81
+ "start": {
82
+ "line": 2,
83
+ "column": 8
84
+ },
85
+ "end": {
86
+ "line": 2,
87
+ "column": 21
88
+ },
89
+ "sourcefile": "new-static.php"
90
+ }
91
+ },
92
+ "operator": "=",
93
+ "cloned": false,
94
+ "_meta": {
95
+ "loc": {
96
+ "start": {
97
+ "line": 2,
98
+ "column": 1
99
+ },
100
+ "end": {
101
+ "line": 2,
102
+ "column": 21
103
+ },
104
+ "sourcefile": "new-static.php"
105
+ }
106
+ },
107
+ "loc": {
108
+ "start": {
109
+ "line": 2,
110
+ "column": 1
111
+ },
112
+ "end": {
113
+ "line": 2,
114
+ "column": 21
115
+ },
116
+ "sourcefile": "new-static.php"
117
+ }
118
+ },
119
+ "_meta": {
120
+ "loc": {
121
+ "start": {
122
+ "line": 2,
123
+ "column": 1
124
+ },
125
+ "end": {
126
+ "line": 2,
127
+ "column": 22
128
+ },
129
+ "sourcefile": "new-static.php"
130
+ }
131
+ },
132
+ "loc": {
133
+ "start": {
134
+ "line": 2,
135
+ "column": 1
136
+ },
137
+ "end": {
138
+ "line": 2,
139
+ "column": 22
140
+ },
141
+ "sourcefile": "new-static.php"
142
+ }
143
+ },
144
+ {
145
+ "type": "ExpressionStatement",
146
+ "expression": {
147
+ "type": "AssignmentExpression",
148
+ "left": {
149
+ "type": "Identifier",
150
+ "name": "v",
151
+ "_meta": {
152
+ "loc": {
153
+ "start": {
154
+ "line": 3,
155
+ "column": 1
156
+ },
157
+ "end": {
158
+ "line": 3,
159
+ "column": 3
160
+ },
161
+ "sourcefile": "new-static.php"
162
+ }
163
+ },
164
+ "loc": {
165
+ "start": {
166
+ "line": 3,
167
+ "column": 1
168
+ },
169
+ "end": {
170
+ "line": 3,
171
+ "column": 3
172
+ },
173
+ "sourcefile": "new-static.php"
174
+ }
175
+ },
176
+ "right": {
177
+ "type": "CallExpression",
178
+ "callee": {
179
+ "type": "MemberAccess",
180
+ "object": {
181
+ "type": "Identifier",
182
+ "name": "Foo",
183
+ "_meta": {
184
+ "loc": {
185
+ "start": {
186
+ "line": 3,
187
+ "column": 6
188
+ },
189
+ "end": {
190
+ "line": 3,
191
+ "column": 9
192
+ },
193
+ "sourcefile": "new-static.php"
194
+ }
195
+ },
196
+ "loc": {
197
+ "start": {
198
+ "line": 3,
199
+ "column": 6
200
+ },
201
+ "end": {
202
+ "line": 3,
203
+ "column": 9
204
+ },
205
+ "sourcefile": "new-static.php"
206
+ }
207
+ },
208
+ "property": {
209
+ "type": "Identifier",
210
+ "name": "bar",
211
+ "_meta": {
212
+ "loc": {
213
+ "start": {
214
+ "line": 3,
215
+ "column": 11
216
+ },
217
+ "end": {
218
+ "line": 3,
219
+ "column": 14
220
+ },
221
+ "sourcefile": "new-static.php"
222
+ }
223
+ },
224
+ "loc": {
225
+ "start": {
226
+ "line": 3,
227
+ "column": 11
228
+ },
229
+ "end": {
230
+ "line": 3,
231
+ "column": 14
232
+ },
233
+ "sourcefile": "new-static.php"
234
+ }
235
+ },
236
+ "computed": false,
237
+ "_meta": {
238
+ "isStatic": true,
239
+ "loc": {
240
+ "start": {
241
+ "line": 3,
242
+ "column": 6
243
+ },
244
+ "end": {
245
+ "line": 3,
246
+ "column": 20
247
+ },
248
+ "sourcefile": "new-static.php"
249
+ }
250
+ },
251
+ "loc": {
252
+ "start": {
253
+ "line": 3,
254
+ "column": 6
255
+ },
256
+ "end": {
257
+ "line": 3,
258
+ "column": 20
259
+ },
260
+ "sourcefile": "new-static.php"
261
+ }
262
+ },
263
+ "arguments": [
264
+ {
265
+ "type": "Identifier",
266
+ "name": "obj",
267
+ "_meta": {
268
+ "loc": {
269
+ "start": {
270
+ "line": 3,
271
+ "column": 15
272
+ },
273
+ "end": {
274
+ "line": 3,
275
+ "column": 19
276
+ },
277
+ "sourcefile": "new-static.php"
278
+ }
279
+ },
280
+ "loc": {
281
+ "start": {
282
+ "line": 3,
283
+ "column": 15
284
+ },
285
+ "end": {
286
+ "line": 3,
287
+ "column": 19
288
+ },
289
+ "sourcefile": "new-static.php"
290
+ }
291
+ }
292
+ ],
293
+ "_meta": {
294
+ "loc": {
295
+ "start": {
296
+ "line": 3,
297
+ "column": 6
298
+ },
299
+ "end": {
300
+ "line": 3,
301
+ "column": 20
302
+ },
303
+ "sourcefile": "new-static.php"
304
+ }
305
+ },
306
+ "loc": {
307
+ "start": {
308
+ "line": 3,
309
+ "column": 6
310
+ },
311
+ "end": {
312
+ "line": 3,
313
+ "column": 20
314
+ },
315
+ "sourcefile": "new-static.php"
316
+ }
317
+ },
318
+ "operator": "=",
319
+ "cloned": false,
320
+ "_meta": {
321
+ "loc": {
322
+ "start": {
323
+ "line": 3,
324
+ "column": 1
325
+ },
326
+ "end": {
327
+ "line": 3,
328
+ "column": 20
329
+ },
330
+ "sourcefile": "new-static.php"
331
+ }
332
+ },
333
+ "loc": {
334
+ "start": {
335
+ "line": 3,
336
+ "column": 1
337
+ },
338
+ "end": {
339
+ "line": 3,
340
+ "column": 20
341
+ },
342
+ "sourcefile": "new-static.php"
343
+ }
344
+ },
345
+ "_meta": {
346
+ "loc": {
347
+ "start": {
348
+ "line": 3,
349
+ "column": 1
350
+ },
351
+ "end": {
352
+ "line": 3,
353
+ "column": 21
354
+ },
355
+ "sourcefile": "new-static.php"
356
+ }
357
+ },
358
+ "loc": {
359
+ "start": {
360
+ "line": 3,
361
+ "column": 1
362
+ },
363
+ "end": {
364
+ "line": 3,
365
+ "column": 21
366
+ },
367
+ "sourcefile": "new-static.php"
368
+ }
369
+ }
370
+ ],
371
+ "language": "php",
372
+ "languageVersion": null,
373
+ "uri": "new-static.php",
374
+ "version": "0.0.0",
375
+ "_meta": {
376
+ "loc": {
377
+ "start": {
378
+ "line": 1,
379
+ "column": 1
380
+ },
381
+ "end": {
382
+ "line": 4,
383
+ "column": 1
384
+ },
385
+ "sourcefile": "new-static.php"
386
+ }
387
+ },
388
+ "loc": {
389
+ "start": {
390
+ "line": 1,
391
+ "column": 1
392
+ },
393
+ "end": {
394
+ "line": 4,
395
+ "column": 1
396
+ },
397
+ "sourcefile": "new-static.php"
398
+ }
399
+ }