@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,7 @@
1
+ <?php
2
+ function foo($x, $y = 1) {
3
+ if ($x) {
4
+ return bar($y);
5
+ }
6
+ return 0;
7
+ }
@@ -0,0 +1,536 @@
1
+ {
2
+ "type": "CompileUnit",
3
+ "body": [
4
+ {
5
+ "type": "FunctionDefinition",
6
+ "id": {
7
+ "type": "Identifier",
8
+ "name": "foo",
9
+ "_meta": {
10
+ "loc": {
11
+ "start": {
12
+ "line": 2,
13
+ "column": 10
14
+ },
15
+ "end": {
16
+ "line": 2,
17
+ "column": 13
18
+ },
19
+ "sourcefile": "function.php"
20
+ }
21
+ },
22
+ "loc": {
23
+ "start": {
24
+ "line": 2,
25
+ "column": 10
26
+ },
27
+ "end": {
28
+ "line": 2,
29
+ "column": 13
30
+ },
31
+ "sourcefile": "function.php"
32
+ }
33
+ },
34
+ "parameters": [
35
+ {
36
+ "type": "VariableDeclaration",
37
+ "id": {
38
+ "type": "Identifier",
39
+ "name": "x",
40
+ "_meta": {
41
+ "loc": {
42
+ "start": {
43
+ "line": 2,
44
+ "column": 14
45
+ },
46
+ "end": {
47
+ "line": 2,
48
+ "column": 16
49
+ },
50
+ "sourcefile": "function.php"
51
+ }
52
+ },
53
+ "loc": {
54
+ "start": {
55
+ "line": 2,
56
+ "column": 14
57
+ },
58
+ "end": {
59
+ "line": 2,
60
+ "column": 16
61
+ },
62
+ "sourcefile": "function.php"
63
+ }
64
+ },
65
+ "init": null,
66
+ "cloned": false,
67
+ "varType": {
68
+ "type": "DynamicType",
69
+ "id": null,
70
+ "_meta": {}
71
+ },
72
+ "_meta": {
73
+ "variadic": false,
74
+ "loc": {
75
+ "start": {
76
+ "line": 2,
77
+ "column": 14
78
+ },
79
+ "end": {
80
+ "line": 2,
81
+ "column": 16
82
+ },
83
+ "sourcefile": "function.php"
84
+ }
85
+ },
86
+ "loc": {
87
+ "start": {
88
+ "line": 2,
89
+ "column": 14
90
+ },
91
+ "end": {
92
+ "line": 2,
93
+ "column": 16
94
+ },
95
+ "sourcefile": "function.php"
96
+ }
97
+ },
98
+ {
99
+ "type": "VariableDeclaration",
100
+ "id": {
101
+ "type": "Identifier",
102
+ "name": "y",
103
+ "_meta": {
104
+ "loc": {
105
+ "start": {
106
+ "line": 2,
107
+ "column": 18
108
+ },
109
+ "end": {
110
+ "line": 2,
111
+ "column": 20
112
+ },
113
+ "sourcefile": "function.php"
114
+ }
115
+ },
116
+ "loc": {
117
+ "start": {
118
+ "line": 2,
119
+ "column": 18
120
+ },
121
+ "end": {
122
+ "line": 2,
123
+ "column": 20
124
+ },
125
+ "sourcefile": "function.php"
126
+ }
127
+ },
128
+ "init": {
129
+ "type": "Literal",
130
+ "value": 1,
131
+ "literalType": "number",
132
+ "_meta": {
133
+ "loc": {
134
+ "start": {
135
+ "line": 2,
136
+ "column": 23
137
+ },
138
+ "end": {
139
+ "line": 2,
140
+ "column": 24
141
+ },
142
+ "sourcefile": "function.php"
143
+ }
144
+ },
145
+ "loc": {
146
+ "start": {
147
+ "line": 2,
148
+ "column": 23
149
+ },
150
+ "end": {
151
+ "line": 2,
152
+ "column": 24
153
+ },
154
+ "sourcefile": "function.php"
155
+ }
156
+ },
157
+ "cloned": false,
158
+ "varType": {
159
+ "type": "DynamicType",
160
+ "id": null,
161
+ "_meta": {}
162
+ },
163
+ "_meta": {
164
+ "variadic": false,
165
+ "loc": {
166
+ "start": {
167
+ "line": 2,
168
+ "column": 18
169
+ },
170
+ "end": {
171
+ "line": 2,
172
+ "column": 24
173
+ },
174
+ "sourcefile": "function.php"
175
+ }
176
+ },
177
+ "loc": {
178
+ "start": {
179
+ "line": 2,
180
+ "column": 18
181
+ },
182
+ "end": {
183
+ "line": 2,
184
+ "column": 24
185
+ },
186
+ "sourcefile": "function.php"
187
+ }
188
+ }
189
+ ],
190
+ "returnType": {
191
+ "type": "DynamicType",
192
+ "id": null,
193
+ "_meta": {}
194
+ },
195
+ "body": {
196
+ "type": "ScopedStatement",
197
+ "body": [
198
+ {
199
+ "type": "IfStatement",
200
+ "test": {
201
+ "type": "Identifier",
202
+ "name": "x",
203
+ "_meta": {
204
+ "loc": {
205
+ "start": {
206
+ "line": 3,
207
+ "column": 9
208
+ },
209
+ "end": {
210
+ "line": 3,
211
+ "column": 11
212
+ },
213
+ "sourcefile": "function.php"
214
+ }
215
+ },
216
+ "loc": {
217
+ "start": {
218
+ "line": 3,
219
+ "column": 9
220
+ },
221
+ "end": {
222
+ "line": 3,
223
+ "column": 11
224
+ },
225
+ "sourcefile": "function.php"
226
+ }
227
+ },
228
+ "consequent": {
229
+ "type": "ScopedStatement",
230
+ "body": [
231
+ {
232
+ "type": "ReturnStatement",
233
+ "argument": {
234
+ "type": "CallExpression",
235
+ "callee": {
236
+ "type": "Identifier",
237
+ "name": "bar",
238
+ "_meta": {
239
+ "loc": {
240
+ "start": {
241
+ "line": 4,
242
+ "column": 16
243
+ },
244
+ "end": {
245
+ "line": 4,
246
+ "column": 19
247
+ },
248
+ "sourcefile": "function.php"
249
+ }
250
+ },
251
+ "loc": {
252
+ "start": {
253
+ "line": 4,
254
+ "column": 16
255
+ },
256
+ "end": {
257
+ "line": 4,
258
+ "column": 19
259
+ },
260
+ "sourcefile": "function.php"
261
+ }
262
+ },
263
+ "arguments": [
264
+ {
265
+ "type": "Identifier",
266
+ "name": "y",
267
+ "_meta": {
268
+ "loc": {
269
+ "start": {
270
+ "line": 4,
271
+ "column": 20
272
+ },
273
+ "end": {
274
+ "line": 4,
275
+ "column": 22
276
+ },
277
+ "sourcefile": "function.php"
278
+ }
279
+ },
280
+ "loc": {
281
+ "start": {
282
+ "line": 4,
283
+ "column": 20
284
+ },
285
+ "end": {
286
+ "line": 4,
287
+ "column": 22
288
+ },
289
+ "sourcefile": "function.php"
290
+ }
291
+ }
292
+ ],
293
+ "_meta": {
294
+ "loc": {
295
+ "start": {
296
+ "line": 4,
297
+ "column": 16
298
+ },
299
+ "end": {
300
+ "line": 4,
301
+ "column": 23
302
+ },
303
+ "sourcefile": "function.php"
304
+ }
305
+ },
306
+ "loc": {
307
+ "start": {
308
+ "line": 4,
309
+ "column": 16
310
+ },
311
+ "end": {
312
+ "line": 4,
313
+ "column": 23
314
+ },
315
+ "sourcefile": "function.php"
316
+ }
317
+ },
318
+ "isYield": false,
319
+ "_meta": {
320
+ "loc": {
321
+ "start": {
322
+ "line": 4,
323
+ "column": 9
324
+ },
325
+ "end": {
326
+ "line": 4,
327
+ "column": 24
328
+ },
329
+ "sourcefile": "function.php"
330
+ }
331
+ },
332
+ "loc": {
333
+ "start": {
334
+ "line": 4,
335
+ "column": 9
336
+ },
337
+ "end": {
338
+ "line": 4,
339
+ "column": 24
340
+ },
341
+ "sourcefile": "function.php"
342
+ }
343
+ }
344
+ ],
345
+ "id": null,
346
+ "_meta": {
347
+ "loc": {
348
+ "start": {
349
+ "line": 3,
350
+ "column": 13
351
+ },
352
+ "end": {
353
+ "line": 5,
354
+ "column": 6
355
+ },
356
+ "sourcefile": "function.php"
357
+ }
358
+ },
359
+ "loc": {
360
+ "start": {
361
+ "line": 3,
362
+ "column": 13
363
+ },
364
+ "end": {
365
+ "line": 5,
366
+ "column": 6
367
+ },
368
+ "sourcefile": "function.php"
369
+ }
370
+ },
371
+ "alternative": null,
372
+ "_meta": {
373
+ "loc": {
374
+ "start": {
375
+ "line": 3,
376
+ "column": 5
377
+ },
378
+ "end": {
379
+ "line": 5,
380
+ "column": 6
381
+ },
382
+ "sourcefile": "function.php"
383
+ }
384
+ },
385
+ "loc": {
386
+ "start": {
387
+ "line": 3,
388
+ "column": 5
389
+ },
390
+ "end": {
391
+ "line": 5,
392
+ "column": 6
393
+ },
394
+ "sourcefile": "function.php"
395
+ }
396
+ },
397
+ {
398
+ "type": "ReturnStatement",
399
+ "argument": {
400
+ "type": "Literal",
401
+ "value": 0,
402
+ "literalType": "number",
403
+ "_meta": {
404
+ "loc": {
405
+ "start": {
406
+ "line": 6,
407
+ "column": 12
408
+ },
409
+ "end": {
410
+ "line": 6,
411
+ "column": 13
412
+ },
413
+ "sourcefile": "function.php"
414
+ }
415
+ },
416
+ "loc": {
417
+ "start": {
418
+ "line": 6,
419
+ "column": 12
420
+ },
421
+ "end": {
422
+ "line": 6,
423
+ "column": 13
424
+ },
425
+ "sourcefile": "function.php"
426
+ }
427
+ },
428
+ "isYield": false,
429
+ "_meta": {
430
+ "loc": {
431
+ "start": {
432
+ "line": 6,
433
+ "column": 5
434
+ },
435
+ "end": {
436
+ "line": 6,
437
+ "column": 14
438
+ },
439
+ "sourcefile": "function.php"
440
+ }
441
+ },
442
+ "loc": {
443
+ "start": {
444
+ "line": 6,
445
+ "column": 5
446
+ },
447
+ "end": {
448
+ "line": 6,
449
+ "column": 14
450
+ },
451
+ "sourcefile": "function.php"
452
+ }
453
+ }
454
+ ],
455
+ "id": null,
456
+ "_meta": {
457
+ "loc": {
458
+ "start": {
459
+ "line": 2,
460
+ "column": 26
461
+ },
462
+ "end": {
463
+ "line": 7,
464
+ "column": 2
465
+ },
466
+ "sourcefile": "function.php"
467
+ }
468
+ },
469
+ "loc": {
470
+ "start": {
471
+ "line": 2,
472
+ "column": 26
473
+ },
474
+ "end": {
475
+ "line": 7,
476
+ "column": 2
477
+ },
478
+ "sourcefile": "function.php"
479
+ }
480
+ },
481
+ "modifiers": [],
482
+ "_meta": {
483
+ "loc": {
484
+ "start": {
485
+ "line": 2,
486
+ "column": 1
487
+ },
488
+ "end": {
489
+ "line": 7,
490
+ "column": 2
491
+ },
492
+ "sourcefile": "function.php"
493
+ }
494
+ },
495
+ "loc": {
496
+ "start": {
497
+ "line": 2,
498
+ "column": 1
499
+ },
500
+ "end": {
501
+ "line": 7,
502
+ "column": 2
503
+ },
504
+ "sourcefile": "function.php"
505
+ }
506
+ }
507
+ ],
508
+ "language": "php",
509
+ "languageVersion": null,
510
+ "uri": "function.php",
511
+ "version": "0.0.0",
512
+ "_meta": {
513
+ "loc": {
514
+ "start": {
515
+ "line": 1,
516
+ "column": 1
517
+ },
518
+ "end": {
519
+ "line": 8,
520
+ "column": 1
521
+ },
522
+ "sourcefile": "function.php"
523
+ }
524
+ },
525
+ "loc": {
526
+ "start": {
527
+ "line": 1,
528
+ "column": 1
529
+ },
530
+ "end": {
531
+ "line": 8,
532
+ "column": 1
533
+ },
534
+ "sourcefile": "function.php"
535
+ }
536
+ }
@@ -0,0 +1,13 @@
1
+ <?php
2
+
3
+ #[Route('/a')]
4
+ class Service
5
+ {
6
+ use LoggerTrait, CacheTrait;
7
+
8
+ #[Inject(name: 'db')]
9
+ public function run(#[Tag('x')] $x)
10
+ {
11
+ return foo(name: $x, count: 1);
12
+ }
13
+ }