@flarum/cli 2.0.2 → 3.0.1

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 (623) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +40 -22
  3. package/boilerplate/skeleton/extension/.github/workflows/backend.yml +1 -1
  4. package/boilerplate/skeleton/extension/.github/workflows/frontend.yml +2 -1
  5. package/boilerplate/skeleton/extension/.github/workflows/phpstan.yml +12 -0
  6. package/boilerplate/skeleton/extension/composer.json +8 -4
  7. package/boilerplate/skeleton/extension/gitignore +1 -0
  8. package/boilerplate/skeleton/extension/js/jest.config.cjs +1 -0
  9. package/boilerplate/skeleton/extension/js/package.json +6 -3
  10. package/boilerplate/skeleton/extension/js/src/admin/extend.js +8 -0
  11. package/boilerplate/skeleton/extension/js/src/admin/extend.ts +8 -0
  12. package/boilerplate/skeleton/extension/js/src/admin/index.js +2 -0
  13. package/boilerplate/skeleton/extension/js/src/admin/index.ts +3 -1
  14. package/boilerplate/skeleton/extension/js/src/common/extend.js +5 -0
  15. package/boilerplate/skeleton/extension/js/src/common/extend.ts +5 -0
  16. package/boilerplate/skeleton/extension/js/src/common/index.ts +1 -1
  17. package/boilerplate/skeleton/extension/js/src/forum/extend.js +8 -0
  18. package/boilerplate/skeleton/extension/js/src/forum/extend.ts +8 -0
  19. package/boilerplate/skeleton/extension/js/src/forum/index.js +2 -0
  20. package/boilerplate/skeleton/extension/js/src/forum/index.ts +3 -1
  21. package/boilerplate/skeleton/extension/js/tests/unit/.gitkeep +0 -0
  22. package/boilerplate/skeleton/extension/js/tsconfig.test.json +10 -0
  23. package/boilerplate/skeleton/extension/locale/en.yml +1 -1
  24. package/boilerplate/skeleton/extension/phpstan.neon +12 -0
  25. package/boilerplate/skeleton/extension/tests/phpunit.integration.xml +5 -7
  26. package/boilerplate/skeleton/extension/tests/phpunit.unit.xml +5 -10
  27. package/boilerplate/stubs/backend/advanced-api-resource.php +85 -0
  28. package/boilerplate/stubs/backend/api-resource.php +73 -0
  29. package/boilerplate/stubs/backend/command.php +2 -2
  30. package/boilerplate/stubs/backend/controller.php +19 -0
  31. package/boilerplate/stubs/backend/event-listener.php +1 -1
  32. package/boilerplate/stubs/backend/filter.php +25 -0
  33. package/boilerplate/stubs/backend/handler/command.php +6 -20
  34. package/boilerplate/stubs/backend/handler/handler.php +6 -14
  35. package/boilerplate/stubs/backend/integration-test.php +10 -7
  36. package/boilerplate/stubs/backend/job.php +6 -11
  37. package/boilerplate/stubs/backend/mail-driver.php +36 -0
  38. package/boilerplate/stubs/backend/middleware.php +19 -0
  39. package/boilerplate/stubs/backend/model.php +1 -1
  40. package/boilerplate/stubs/backend/notification-blueprint.php +42 -0
  41. package/boilerplate/stubs/backend/notification-driver.php +32 -0
  42. package/boilerplate/stubs/backend/policy.php +1 -1
  43. package/boilerplate/stubs/backend/post-type.php +35 -0
  44. package/boilerplate/stubs/backend/repository.php +2 -10
  45. package/boilerplate/stubs/backend/search/driver.php +13 -0
  46. package/boilerplate/stubs/backend/search/searcher.php +41 -0
  47. package/boilerplate/stubs/backend/service-provider.php +1 -1
  48. package/boilerplate/stubs/backend/validator.php +1 -1
  49. package/boilerplate/stubs/frontend/component.js +1 -1
  50. package/boilerplate/stubs/frontend/forum-page.js +68 -0
  51. package/boilerplate/stubs/frontend/gambit/boolean.js +12 -0
  52. package/boilerplate/stubs/frontend/gambit/key-value.js +16 -0
  53. package/boilerplate/stubs/frontend/modal.js +1 -1
  54. package/boilerplate/stubs/frontend/model.js +1 -1
  55. package/boilerplate/stubs/frontend/notification.js +22 -0
  56. package/boilerplate/stubs/frontend/post-type.js +13 -0
  57. package/boilerplate/stubs/migration.php +1 -1
  58. package/boilerplate/stubs/views/email/html/information.blade.php +8 -0
  59. package/boilerplate/stubs/views/email/html/notification.blade.php +8 -0
  60. package/boilerplate/stubs/views/email/plain/information.blade.php +7 -0
  61. package/boilerplate/stubs/views/email/plain/notification.blade.php +6 -0
  62. package/lib/base-command.d.ts +19 -5
  63. package/lib/base-command.js +73 -28
  64. package/lib/boilersmith/io.d.ts +9 -7
  65. package/lib/boilersmith/io.js +28 -15
  66. package/lib/boilersmith/paths.d.ts +1 -1
  67. package/lib/boilersmith/scaffolding/audit-step-factory.js +1 -1
  68. package/lib/boilersmith/scaffolding/module.d.ts +4 -4
  69. package/lib/boilersmith/scaffolding/module.js +6 -6
  70. package/lib/boilersmith/scaffolding/scaffolder.d.ts +1 -1
  71. package/lib/boilersmith/scaffolding/scaffolder.js +1 -1
  72. package/lib/boilersmith/scaffolding/template-param.d.ts +1 -1
  73. package/lib/boilersmith/step-manager.d.ts +15 -10
  74. package/lib/boilersmith/step-manager.js +35 -9
  75. package/lib/boilersmith/steps/stub-base.js +1 -1
  76. package/lib/boilersmith/utils/json-leaf-paths.d.ts +2 -2
  77. package/lib/commands/audit/infra.d.ts +1 -4
  78. package/lib/commands/audit/infra.js +1 -1
  79. package/lib/commands/flarum/change.js +2 -2
  80. package/lib/commands/flarum/info.js +1 -1
  81. package/lib/commands/infra.d.ts +1 -9
  82. package/lib/commands/infra.js +2 -2
  83. package/lib/commands/init.d.ts +1 -4
  84. package/lib/commands/init.js +3 -3
  85. package/lib/commands/make/backend/{api-serializer.d.ts → api-resource.d.ts} +2 -5
  86. package/lib/commands/make/backend/api-resource.js +26 -0
  87. package/lib/commands/make/backend/command.d.ts +1 -4
  88. package/lib/commands/make/backend/command.js +2 -2
  89. package/lib/commands/make/backend/{api-controller.d.ts → controller.d.ts} +2 -5
  90. package/lib/commands/make/backend/controller.js +31 -0
  91. package/lib/commands/make/backend/event-listener.d.ts +1 -4
  92. package/lib/commands/make/backend/event-listener.js +1 -1
  93. package/lib/commands/make/backend/{api-serializer-attributes.d.ts → filter.d.ts} +3 -6
  94. package/lib/commands/make/backend/filter.js +26 -0
  95. package/lib/commands/make/backend/handler.d.ts +2 -5
  96. package/lib/commands/make/backend/handler.js +6 -6
  97. package/lib/commands/make/backend/integration-test.d.ts +1 -4
  98. package/lib/commands/make/backend/integration-test.js +2 -2
  99. package/lib/commands/make/backend/job.d.ts +1 -4
  100. package/lib/commands/make/backend/job.js +2 -2
  101. package/lib/commands/make/backend/mail-driver.d.ts +12 -0
  102. package/lib/commands/make/backend/mail-driver.js +29 -0
  103. package/lib/commands/make/backend/middleware.d.ts +11 -0
  104. package/lib/commands/make/backend/middleware.js +26 -0
  105. package/lib/commands/make/backend/migration.d.ts +1 -4
  106. package/lib/commands/make/backend/migration.js +9 -2
  107. package/lib/commands/make/backend/model.d.ts +6 -7
  108. package/lib/commands/make/backend/model.js +68 -447
  109. package/lib/commands/make/backend/notification-blueprint.d.ts +12 -0
  110. package/lib/commands/make/backend/notification-blueprint.js +29 -0
  111. package/lib/commands/make/backend/notification-driver.d.ts +12 -0
  112. package/lib/commands/make/backend/notification-driver.js +29 -0
  113. package/lib/commands/make/backend/policy.d.ts +1 -4
  114. package/lib/commands/make/backend/policy.js +1 -1
  115. package/lib/commands/make/backend/post-type.d.ts +12 -0
  116. package/lib/commands/make/backend/post-type.js +29 -0
  117. package/lib/commands/make/backend/repository.d.ts +1 -4
  118. package/lib/commands/make/backend/repository.js +1 -1
  119. package/lib/commands/make/backend/route.d.ts +1 -4
  120. package/lib/commands/make/backend/route.js +1 -1
  121. package/lib/commands/make/backend/search-driver.d.ts +11 -0
  122. package/lib/commands/make/backend/search-driver.js +51 -0
  123. package/lib/commands/make/backend/service-provider.d.ts +1 -4
  124. package/lib/commands/make/backend/service-provider.js +2 -2
  125. package/lib/commands/make/backend/validator.d.ts +1 -4
  126. package/lib/commands/make/backend/validator.js +2 -2
  127. package/lib/commands/make/frontend/component.d.ts +4 -5
  128. package/lib/commands/make/frontend/component.js +7 -2
  129. package/lib/commands/make/frontend/forum-page.d.ts +11 -0
  130. package/lib/commands/make/frontend/forum-page.js +92 -0
  131. package/lib/commands/make/frontend/gambit.d.ts +11 -0
  132. package/lib/commands/make/frontend/gambit.js +30 -0
  133. package/lib/commands/make/frontend/modal.d.ts +1 -4
  134. package/lib/commands/make/frontend/modal.js +3 -2
  135. package/lib/commands/make/frontend/model.d.ts +6 -7
  136. package/lib/commands/make/frontend/model.js +26 -24
  137. package/lib/commands/make/frontend/notification.d.ts +12 -0
  138. package/lib/commands/make/frontend/notification.js +62 -0
  139. package/lib/commands/make/frontend/post-type.d.ts +12 -0
  140. package/lib/commands/make/frontend/post-type.js +59 -0
  141. package/lib/commands/make/locale.d.ts +11 -0
  142. package/lib/commands/make/locale.js +27 -0
  143. package/lib/commands/make/model.d.ts +12 -0
  144. package/lib/commands/make/model.js +29 -0
  145. package/lib/commands/make/notification.d.ts +11 -0
  146. package/lib/commands/make/notification.js +33 -0
  147. package/lib/commands/make/post-type.d.ts +11 -0
  148. package/lib/commands/make/post-type.js +31 -0
  149. package/lib/commands/monorepo/create.d.ts +1 -4
  150. package/lib/commands/monorepo/create.js +1 -1
  151. package/lib/commands/monorepo/split.d.ts +1 -4
  152. package/lib/commands/monorepo/split.js +1 -1
  153. package/lib/commands/update/js-imports.d.ts +1 -4
  154. package/lib/commands/update/js-imports.js +1 -1
  155. package/lib/commands/upgrade/2.0.d.ts +17 -0
  156. package/lib/commands/upgrade/2.0.js +113 -0
  157. package/lib/help.js +1 -1
  158. package/lib/providers/php-provider.d.ts +7 -1
  159. package/lib/providers/php-provider.js +16 -3
  160. package/lib/steps/extenders/{api-serializer.d.ts → api-resource.d.ts} +1 -1
  161. package/lib/steps/extenders/api-resource.js +38 -0
  162. package/lib/steps/extenders/base.d.ts +1 -1
  163. package/lib/steps/extenders/base.js +13 -1
  164. package/lib/steps/extenders/console-command.js +1 -1
  165. package/lib/steps/extenders/event.js +1 -1
  166. package/lib/steps/extenders/mail-driver.d.ts +5 -0
  167. package/lib/steps/extenders/mail-driver.js +58 -0
  168. package/lib/steps/extenders/middleware.d.ts +5 -0
  169. package/lib/steps/extenders/middleware.js +57 -0
  170. package/lib/steps/extenders/notification-driver.d.ts +5 -0
  171. package/lib/steps/extenders/notification-driver.js +58 -0
  172. package/lib/steps/extenders/notification-type.d.ts +5 -0
  173. package/lib/steps/extenders/notification-type.js +55 -0
  174. package/lib/steps/extenders/policy.js +1 -1
  175. package/lib/steps/extenders/post-type.d.ts +5 -0
  176. package/lib/steps/extenders/post-type.js +42 -0
  177. package/lib/steps/extenders/route.js +11 -2
  178. package/lib/steps/extenders/search-driver.d.ts +5 -0
  179. package/lib/steps/extenders/search-driver.js +38 -0
  180. package/lib/steps/extenders/search-filter.d.ts +5 -0
  181. package/lib/steps/extenders/search-filter.js +67 -0
  182. package/lib/steps/extenders/service-provider.js +1 -1
  183. package/lib/steps/gen-ext-scaffolder.d.ts +3 -3
  184. package/lib/steps/gen-ext-scaffolder.js +79 -7
  185. package/lib/steps/js/base.d.ts +14 -5
  186. package/lib/steps/js/base.js +101 -25
  187. package/lib/steps/js/model.d.ts +4 -7
  188. package/lib/steps/js/model.js +45 -19
  189. package/lib/steps/js/notification.d.ts +7 -0
  190. package/lib/steps/js/notification.js +58 -0
  191. package/lib/steps/js/post-type.d.ts +8 -0
  192. package/lib/steps/js/post-type.js +60 -0
  193. package/lib/steps/js/routes.d.ts +7 -0
  194. package/lib/steps/js/routes.js +63 -0
  195. package/lib/steps/js/search-driver-locale.d.ts +8 -0
  196. package/lib/steps/js/search-driver-locale.js +36 -0
  197. package/lib/steps/js/search-gambit.d.ts +7 -0
  198. package/lib/steps/js/search-gambit.js +51 -0
  199. package/lib/steps/locale/base.d.ts +32 -0
  200. package/lib/steps/locale/base.js +97 -0
  201. package/lib/steps/misc/git.js +1 -1
  202. package/lib/steps/monorepo/create.d.ts +2 -0
  203. package/lib/steps/monorepo/create.js +5 -4
  204. package/lib/steps/monorepo/split.js +1 -1
  205. package/lib/steps/stubs/backend/advanced-api-resource.d.ts +13 -0
  206. package/lib/steps/stubs/backend/advanced-api-resource.js +81 -0
  207. package/lib/steps/stubs/backend/{api-serializer.d.ts → api-resource.d.ts} +1 -1
  208. package/lib/steps/stubs/backend/{api-serializer.js → api-resource.js} +9 -9
  209. package/lib/steps/stubs/backend/command.d.ts +2 -16
  210. package/lib/steps/stubs/backend/command.js +14 -1
  211. package/lib/steps/stubs/backend/{api-controller.d.ts → controller.d.ts} +3 -13
  212. package/lib/steps/stubs/backend/controller.js +40 -0
  213. package/lib/steps/stubs/backend/event-listener.js +1 -1
  214. package/lib/steps/stubs/backend/filter.d.ts +8 -0
  215. package/lib/steps/stubs/backend/filter.js +44 -0
  216. package/lib/steps/stubs/backend/handler-command.d.ts +2 -27
  217. package/lib/steps/stubs/backend/handler-command.js +2 -1
  218. package/lib/steps/stubs/backend/handler.js +1 -1
  219. package/lib/steps/stubs/backend/integration-test.js +0 -5
  220. package/lib/steps/stubs/backend/mail-driver.d.ts +7 -0
  221. package/lib/steps/stubs/backend/mail-driver.js +30 -0
  222. package/lib/steps/stubs/backend/middleware.d.ts +22 -0
  223. package/lib/steps/stubs/backend/middleware.js +31 -0
  224. package/lib/steps/stubs/backend/model.d.ts +2 -24
  225. package/lib/steps/stubs/backend/model.js +2 -5
  226. package/lib/steps/stubs/backend/notification-blueprint.d.ts +7 -0
  227. package/lib/steps/stubs/backend/notification-blueprint.js +44 -0
  228. package/lib/steps/stubs/backend/notification-driver.d.ts +7 -0
  229. package/lib/steps/stubs/backend/notification-driver.js +30 -0
  230. package/lib/steps/stubs/backend/policy.js +1 -1
  231. package/lib/steps/stubs/backend/post-type.d.ts +7 -0
  232. package/lib/steps/stubs/backend/post-type.js +44 -0
  233. package/lib/steps/stubs/backend/repository.js +1 -1
  234. package/lib/steps/stubs/backend/search-driver-searcher.d.ts +24 -0
  235. package/lib/steps/stubs/backend/search-driver-searcher.js +32 -0
  236. package/lib/steps/stubs/backend/search-driver.d.ts +8 -0
  237. package/lib/steps/stubs/backend/search-driver.js +49 -0
  238. package/lib/steps/stubs/flarum-base.js +1 -1
  239. package/lib/steps/stubs/frontend/forum-page.d.ts +25 -0
  240. package/lib/steps/stubs/frontend/forum-page.js +37 -0
  241. package/lib/steps/stubs/frontend/gambit.d.ts +7 -0
  242. package/lib/steps/stubs/frontend/gambit.js +50 -0
  243. package/lib/steps/stubs/frontend/model.d.ts +12 -0
  244. package/lib/steps/stubs/frontend/model.js +5 -0
  245. package/lib/steps/stubs/frontend/notification.d.ts +11 -0
  246. package/lib/steps/stubs/frontend/notification.js +48 -0
  247. package/lib/steps/stubs/frontend/post-type.d.ts +11 -0
  248. package/lib/steps/stubs/frontend/post-type.js +48 -0
  249. package/lib/steps/stubs/js-base.js +5 -1
  250. package/lib/steps/stubs/php-base.js +3 -1
  251. package/lib/steps/update/js-imports.js +1 -1
  252. package/lib/steps/upgrade/twopointoh/backend/email-views.d.ts +18 -0
  253. package/lib/steps/upgrade/twopointoh/backend/email-views.js +81 -0
  254. package/lib/steps/upgrade/twopointoh/backend/filesystem.d.ts +8 -0
  255. package/lib/steps/upgrade/twopointoh/backend/filesystem.js +40 -0
  256. package/lib/steps/upgrade/twopointoh/backend/intervention-image.d.ts +8 -0
  257. package/lib/steps/upgrade/twopointoh/backend/intervention-image.js +44 -0
  258. package/lib/steps/upgrade/twopointoh/backend/json-api.d.ts +12 -0
  259. package/lib/steps/upgrade/twopointoh/backend/json-api.js +111 -0
  260. package/lib/steps/upgrade/twopointoh/backend/mailer.d.ts +8 -0
  261. package/lib/steps/upgrade/twopointoh/backend/mailer.js +37 -0
  262. package/lib/steps/upgrade/twopointoh/backend/misc.d.ts +8 -0
  263. package/lib/steps/upgrade/twopointoh/backend/misc.js +42 -0
  264. package/lib/steps/upgrade/twopointoh/backend/phpunit.d.ts +8 -0
  265. package/lib/steps/upgrade/twopointoh/backend/phpunit.js +52 -0
  266. package/lib/steps/upgrade/twopointoh/backend/search.d.ts +28 -0
  267. package/lib/steps/upgrade/twopointoh/backend/search.js +200 -0
  268. package/lib/steps/upgrade/twopointoh/base.d.ts +58 -0
  269. package/lib/steps/upgrade/twopointoh/base.js +284 -0
  270. package/lib/steps/upgrade/twopointoh/dependencies.d.ts +10 -0
  271. package/lib/steps/upgrade/twopointoh/dependencies.js +108 -0
  272. package/lib/steps/upgrade/twopointoh/frontend/code-splitting/usage-of-lazy-modules.d.ts +26 -0
  273. package/lib/steps/upgrade/twopointoh/frontend/code-splitting/usage-of-lazy-modules.js +418 -0
  274. package/lib/steps/upgrade/twopointoh/frontend/export-registry/compat.d.ts +12 -0
  275. package/lib/steps/upgrade/twopointoh/frontend/export-registry/compat.js +75 -0
  276. package/lib/steps/upgrade/twopointoh/frontend/export-registry/import-ext.d.ts +13 -0
  277. package/lib/steps/upgrade/twopointoh/frontend/export-registry/import-ext.js +126 -0
  278. package/lib/steps/upgrade/twopointoh/frontend/format.d.ts +8 -0
  279. package/lib/steps/upgrade/twopointoh/frontend/format.js +32 -0
  280. package/lib/steps/upgrade/twopointoh/frontend/misc.d.ts +17 -0
  281. package/lib/steps/upgrade/twopointoh/frontend/misc.js +433 -0
  282. package/lib/steps/upgrade/twopointoh/infra.d.ts +10 -0
  283. package/lib/steps/upgrade/twopointoh/infra.js +51 -0
  284. package/lib/steps/upgrade/twopointoh/less.d.ts +12 -0
  285. package/lib/steps/upgrade/twopointoh/less.js +217 -0
  286. package/lib/utils/add-extenders.d.ts +2 -0
  287. package/lib/utils/add-extenders.js +115 -0
  288. package/lib/utils/ast.d.ts +22 -0
  289. package/lib/utils/ast.js +235 -0
  290. package/lib/utils/composer.d.ts +1 -1
  291. package/lib/utils/model-name.d.ts +1 -0
  292. package/lib/utils/model-name.js +7 -3
  293. package/lib/utils/monorepo.d.ts +2 -2
  294. package/lib/utils/validation.d.ts +4 -1
  295. package/lib/utils/validation.js +9 -0
  296. package/oclif.manifest.json +1 -1
  297. package/package.json +20 -13
  298. package/php-subsystem/composer.json +3 -1
  299. package/php-subsystem/composer.lock +13 -11
  300. package/php-subsystem/index.php +41 -6
  301. package/php-subsystem/src/CustomPrettyPrinter.php +1 -1
  302. package/php-subsystem/src/ExtenderUtil.php +7 -13
  303. package/php-subsystem/src/NodeUtil.php +72 -0
  304. package/php-subsystem/src/NodeVisitors/AddExtender.php +28 -12
  305. package/php-subsystem/src/NodeVisitors/AddUses.php +24 -0
  306. package/php-subsystem/src/NodeVisitors/ChangeSignatures.php +200 -0
  307. package/php-subsystem/src/NodeVisitors/ReplaceUses.php +175 -0
  308. package/php-subsystem/src/Upgrade/Replacement.php +51 -0
  309. package/php-subsystem/src/Upgrade/ReplacementResult.php +17 -0
  310. package/php-subsystem/src/Upgrade/TwoPointOh/EmailViews.php +94 -0
  311. package/php-subsystem/src/Upgrade/TwoPointOh/Filesystem.php +88 -0
  312. package/php-subsystem/src/Upgrade/TwoPointOh/InterventionImage.php +86 -0
  313. package/php-subsystem/src/Upgrade/TwoPointOh/JsonApi.php +186 -0
  314. package/php-subsystem/src/Upgrade/TwoPointOh/Misc.php +584 -0
  315. package/php-subsystem/src/Upgrade/TwoPointOh/PhpUnit.php +241 -0
  316. package/php-subsystem/src/Upgrade/TwoPointOh/Search.php +589 -0
  317. package/php-subsystem/vendor/autoload.php +18 -0
  318. package/php-subsystem/vendor/bin/php-parse +119 -0
  319. package/php-subsystem/vendor/composer/ClassLoader.php +166 -32
  320. package/php-subsystem/vendor/composer/InstalledVersions.php +350 -209
  321. package/php-subsystem/vendor/composer/autoload_classmap.php +1 -1
  322. package/php-subsystem/vendor/composer/autoload_namespaces.php +1 -1
  323. package/php-subsystem/vendor/composer/autoload_psr4.php +1 -1
  324. package/php-subsystem/vendor/composer/autoload_real.php +3 -22
  325. package/php-subsystem/vendor/composer/installed.json +12 -10
  326. package/php-subsystem/vendor/composer/installed.php +29 -30
  327. package/php-subsystem/vendor/composer/platform_check.php +2 -2
  328. package/php-subsystem/vendor/nikic/php-parser/README.md +74 -62
  329. package/php-subsystem/vendor/nikic/php-parser/bin/php-parse +12 -11
  330. package/php-subsystem/vendor/nikic/php-parser/composer.json +6 -4
  331. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php +58 -11
  332. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/Class_.php +54 -25
  333. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/Declaration.php +11 -4
  334. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/EnumCase.php +87 -0
  335. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/Enum_.php +116 -0
  336. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php +8 -9
  337. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/Function_.php +22 -5
  338. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/Interface_.php +26 -7
  339. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php +31 -13
  340. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/Namespace_.php +5 -5
  341. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php +69 -26
  342. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php +47 -18
  343. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUse.php +6 -5
  344. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php +25 -28
  345. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/Trait_.php +31 -8
  346. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/Use_.php +8 -8
  347. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder.php +2 -3
  348. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/BuilderFactory.php +85 -70
  349. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/BuilderHelpers.php +119 -71
  350. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Comment/Doc.php +1 -2
  351. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Comment.php +35 -67
  352. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/ConstExprEvaluationException.php +3 -3
  353. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/ConstExprEvaluator.php +17 -9
  354. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Error.php +24 -33
  355. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/ErrorHandler/Collecting.php +6 -9
  356. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/ErrorHandler/Throwing.php +2 -3
  357. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/ErrorHandler.php +2 -3
  358. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Internal/DiffElem.php +11 -7
  359. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Internal/Differ.php +36 -22
  360. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Internal/PrintableNewAnonClassNode.php +24 -14
  361. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php +237 -0
  362. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php +63 -69
  363. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/JsonDecoder.php +15 -10
  364. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php +74 -92
  365. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/AttributeEmulator.php +11 -18
  366. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/EnumTokenEmulator.php +10 -15
  367. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ExplicitOctalEmulator.php +45 -0
  368. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/KeywordEmulator.php +19 -25
  369. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/MatchTokenEmulator.php +6 -10
  370. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NullsafeTokenEmulator.php +22 -29
  371. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyFunctionTokenEmulator.php +31 -0
  372. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyTokenEmulator.php +31 -0
  373. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReverseEmulator.php +6 -5
  374. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/TokenEmulator.php +10 -5
  375. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer.php +70 -491
  376. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Modifiers.php +69 -0
  377. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NameContext.php +23 -24
  378. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Arg.php +13 -14
  379. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/ArrayItem.php +43 -0
  380. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Attribute.php +9 -10
  381. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/AttributeGroup.php +5 -7
  382. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/ClosureUse.php +36 -0
  383. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/ComplexType.php +13 -0
  384. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Const_.php +12 -13
  385. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/DeclareItem.php +37 -0
  386. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayDimFetch.php +10 -11
  387. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayItem.php +1 -39
  388. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Array_.php +11 -11
  389. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrowFunction.php +35 -30
  390. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Assign.php +9 -10
  391. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseAnd.php +2 -3
  392. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseOr.php +2 -3
  393. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseXor.php +2 -3
  394. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Coalesce.php +2 -3
  395. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Concat.php +2 -3
  396. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Div.php +2 -3
  397. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Minus.php +2 -3
  398. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Mod.php +2 -3
  399. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Mul.php +2 -3
  400. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Plus.php +2 -3
  401. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Pow.php +2 -3
  402. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/ShiftLeft.php +2 -3
  403. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/ShiftRight.php +2 -3
  404. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp.php +7 -8
  405. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignRef.php +9 -10
  406. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseAnd.php +4 -5
  407. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseOr.php +4 -5
  408. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseXor.php +4 -5
  409. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BooleanAnd.php +4 -5
  410. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BooleanOr.php +4 -5
  411. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Coalesce.php +4 -5
  412. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Concat.php +4 -5
  413. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Div.php +4 -5
  414. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Equal.php +4 -5
  415. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Greater.php +4 -5
  416. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/GreaterOrEqual.php +4 -5
  417. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Identical.php +4 -5
  418. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalAnd.php +4 -5
  419. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalOr.php +4 -5
  420. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalXor.php +4 -5
  421. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Minus.php +4 -5
  422. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Mod.php +4 -5
  423. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Mul.php +4 -5
  424. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/NotEqual.php +4 -5
  425. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/NotIdentical.php +4 -5
  426. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Plus.php +4 -5
  427. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Pow.php +4 -5
  428. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftLeft.php +4 -5
  429. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftRight.php +4 -5
  430. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Smaller.php +4 -5
  431. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/SmallerOrEqual.php +4 -5
  432. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Spaceship.php +4 -5
  433. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp.php +8 -11
  434. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BitwiseNot.php +7 -8
  435. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BooleanNot.php +7 -8
  436. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/CallLike.php +35 -0
  437. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Array_.php +2 -3
  438. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Bool_.php +2 -3
  439. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Double.php +5 -6
  440. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Int_.php +2 -3
  441. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Object_.php +2 -3
  442. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/String_.php +2 -3
  443. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Unset_.php +2 -3
  444. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast.php +5 -6
  445. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ClassConstFetch.php +12 -12
  446. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Clone_.php +7 -8
  447. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Closure.php +34 -27
  448. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ClosureUse.php +1 -32
  449. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ConstFetch.php +7 -8
  450. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Empty_.php +7 -8
  451. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Error.php +5 -6
  452. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ErrorSuppress.php +7 -8
  453. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Eval_.php +7 -8
  454. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Exit_.php +10 -11
  455. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/FuncCall.php +15 -12
  456. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Include_.php +13 -14
  457. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Instanceof_.php +11 -11
  458. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Isset_.php +7 -8
  459. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/List_.php +12 -8
  460. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Match_.php +8 -7
  461. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/MethodCall.php +18 -13
  462. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/New_.php +17 -12
  463. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafeMethodCall.php +18 -13
  464. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafePropertyFetch.php +10 -10
  465. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PostDec.php +7 -8
  466. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PostInc.php +7 -8
  467. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PreDec.php +6 -7
  468. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PreInc.php +7 -8
  469. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Print_.php +7 -8
  470. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PropertyFetch.php +10 -10
  471. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ShellExec.php +9 -9
  472. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/StaticCall.php +19 -14
  473. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/StaticPropertyFetch.php +11 -11
  474. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Ternary.php +12 -13
  475. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Throw_.php +6 -7
  476. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryMinus.php +7 -8
  477. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryPlus.php +7 -8
  478. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Variable.php +6 -7
  479. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/YieldFrom.php +7 -8
  480. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Yield_.php +10 -11
  481. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr.php +1 -2
  482. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/FunctionLike.php +6 -9
  483. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Identifier.php +13 -13
  484. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/InterpolatedStringPart.php +32 -0
  485. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/IntersectionType.php +27 -0
  486. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/MatchArm.php +8 -9
  487. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Name/FullyQualified.php +8 -9
  488. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Name/Relative.php +8 -9
  489. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Name.php +80 -53
  490. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/NullableType.php +10 -11
  491. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Param.php +47 -23
  492. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/PropertyItem.php +37 -0
  493. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/DNumber.php +1 -68
  494. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/Encapsed.php +1 -29
  495. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/EncapsedStringPart.php +1 -28
  496. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/Float_.php +78 -0
  497. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/Int_.php +82 -0
  498. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/InterpolatedString.php +34 -0
  499. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php +1 -71
  500. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Class_.php +4 -5
  501. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Dir.php +4 -5
  502. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/File.php +4 -5
  503. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Function_.php +4 -5
  504. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Line.php +4 -5
  505. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Method.php +4 -5
  506. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Namespace_.php +4 -5
  507. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Trait_.php +4 -5
  508. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst.php +4 -5
  509. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/String_.php +44 -24
  510. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar.php +1 -2
  511. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/StaticVar.php +39 -0
  512. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Block.php +29 -0
  513. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Break_.php +8 -9
  514. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Case_.php +10 -11
  515. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Catch_.php +11 -12
  516. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassConst.php +33 -27
  517. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassLike.php +15 -15
  518. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassMethod.php +66 -71
  519. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Class_.php +48 -61
  520. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Const_.php +7 -8
  521. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Continue_.php +8 -9
  522. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/DeclareDeclare.php +1 -32
  523. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Declare_.php +12 -12
  524. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Do_.php +9 -10
  525. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Echo_.php +7 -8
  526. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ElseIf_.php +9 -10
  527. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Else_.php +7 -8
  528. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/EnumCase.php +11 -12
  529. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Enum_.php +17 -13
  530. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Expression.php +7 -8
  531. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Finally_.php +7 -8
  532. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/For_.php +19 -15
  533. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Foreach_.php +20 -17
  534. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Function_.php +31 -27
  535. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Global_.php +7 -8
  536. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Goto_.php +7 -8
  537. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/GroupUse.php +16 -14
  538. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/HaltCompiler.php +7 -8
  539. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/If_.php +18 -15
  540. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/InlineHTML.php +7 -8
  541. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Interface_.php +13 -10
  542. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Label.php +7 -8
  543. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Namespace_.php +11 -12
  544. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Nop.php +4 -5
  545. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Property.php +35 -36
  546. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/PropertyProperty.php +1 -32
  547. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Return_.php +8 -9
  548. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/StaticVar.php +1 -35
  549. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Static_.php +8 -8
  550. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Switch_.php +9 -10
  551. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUse.php +8 -9
  552. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php +12 -13
  553. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php +9 -10
  554. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation.php +3 -4
  555. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Trait_.php +10 -8
  556. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TryCatch.php +11 -12
  557. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Unset_.php +7 -8
  558. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/UseUse.php +1 -50
  559. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Use_.php +16 -16
  560. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/While_.php +9 -10
  561. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt.php +1 -2
  562. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/UnionType.php +8 -11
  563. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/UseItem.php +55 -0
  564. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/VarLikeIdentifier.php +2 -3
  565. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/VariadicPlaceholder.php +27 -0
  566. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node.php +24 -29
  567. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeAbstract.php +20 -20
  568. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeDumper.php +169 -82
  569. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeFinder.php +28 -19
  570. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php +71 -84
  571. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeTraverserInterface.php +4 -7
  572. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/CloningVisitor.php +1 -2
  573. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/CommentAnnotatingVisitor.php +82 -0
  574. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/FindingVisitor.php +4 -5
  575. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/FirstFindingVisitor.php +6 -7
  576. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/NameResolver.php +40 -24
  577. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/NodeConnectingVisitor.php +2 -3
  578. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/ParentConnectingVisitor.php +8 -11
  579. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor.php +59 -7
  580. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeVisitorAbstract.php +1 -2
  581. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Parser/Php7.php +2011 -2058
  582. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Parser/Php8.php +2717 -0
  583. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Parser.php +9 -3
  584. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php +466 -248
  585. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/ParserFactory.php +31 -33
  586. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php +164 -0
  587. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php +419 -338
  588. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter.php +51 -0
  589. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php +587 -431
  590. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Token.php +18 -0
  591. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/compatibility_tokens.php +63 -0
  592. package/boilerplate/stubs/backend/api-controller/create.php +0 -53
  593. package/boilerplate/stubs/backend/api-controller/delete.php +0 -52
  594. package/boilerplate/stubs/backend/api-controller/list.php +0 -61
  595. package/boilerplate/stubs/backend/api-controller/normal.php +0 -29
  596. package/boilerplate/stubs/backend/api-controller/show.php +0 -48
  597. package/boilerplate/stubs/backend/api-controller/update.php +0 -54
  598. package/boilerplate/stubs/backend/api-serializer.php +0 -36
  599. package/lib/commands/make/backend/api-controller.js +0 -26
  600. package/lib/commands/make/backend/api-serializer-attributes.js +0 -14
  601. package/lib/commands/make/backend/api-serializer.js +0 -15
  602. package/lib/steps/extenders/api-serializer.js +0 -77
  603. package/lib/steps/stubs/backend/api-controller.js +0 -65
  604. package/lib/steps/stubs/frontend/migration.js +0 -1
  605. package/php-subsystem/vendor/nikic/php-parser/.editorconfig +0 -9
  606. package/php-subsystem/vendor/nikic/php-parser/grammar/README.md +0 -27
  607. package/php-subsystem/vendor/nikic/php-parser/grammar/parser.template +0 -106
  608. package/php-subsystem/vendor/nikic/php-parser/grammar/php5.y +0 -1026
  609. package/php-subsystem/vendor/nikic/php-parser/grammar/php7.y +0 -1152
  610. package/php-subsystem/vendor/nikic/php-parser/grammar/phpyLang.php +0 -192
  611. package/php-subsystem/vendor/nikic/php-parser/grammar/rebuildParsers.php +0 -81
  612. package/php-subsystem/vendor/nikic/php-parser/grammar/tokens.template +0 -17
  613. package/php-subsystem/vendor/nikic/php-parser/grammar/tokens.y +0 -115
  614. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/CoaleseEqualTokenEmulator.php +0 -47
  615. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FlexibleDocStringEmulator.php +0 -76
  616. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FnTokenEmulator.php +0 -23
  617. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NumericLiteralSeparatorEmulator.php +0 -105
  618. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Throw_.php +0 -30
  619. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Parser/Multiple.php +0 -55
  620. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Parser/Php5.php +0 -2630
  621. package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Parser/Tokens.php +0 -145
  622. /package/{lib/steps/stubs/frontend/migration.d.ts → boilerplate/skeleton/extension/js/tests/integration/.gitkeep} +0 -0
  623. /package/boilerplate/skeleton/extension/js/{webpack.config.js → webpack.config.cjs} +0 -0
@@ -6,137 +6,160 @@ namespace PhpParser;
6
6
  * This parser is based on a skeleton written by Moriyoshi Koizumi, which in
7
7
  * turn is based on work by Masato Bito.
8
8
  */
9
+
9
10
  use PhpParser\Node\Expr;
11
+ use PhpParser\Node\Expr\Array_;
10
12
  use PhpParser\Node\Expr\Cast\Double;
13
+ use PhpParser\Node\Identifier;
14
+ use PhpParser\Node\InterpolatedStringPart;
11
15
  use PhpParser\Node\Name;
12
16
  use PhpParser\Node\Param;
13
- use PhpParser\Node\Scalar\Encapsed;
14
- use PhpParser\Node\Scalar\LNumber;
17
+ use PhpParser\Node\Scalar\InterpolatedString;
18
+ use PhpParser\Node\Scalar\Int_;
15
19
  use PhpParser\Node\Scalar\String_;
20
+ use PhpParser\Node\Stmt;
16
21
  use PhpParser\Node\Stmt\Class_;
17
22
  use PhpParser\Node\Stmt\ClassConst;
18
23
  use PhpParser\Node\Stmt\ClassMethod;
24
+ use PhpParser\Node\Stmt\Else_;
25
+ use PhpParser\Node\Stmt\ElseIf_;
19
26
  use PhpParser\Node\Stmt\Enum_;
20
27
  use PhpParser\Node\Stmt\Interface_;
21
28
  use PhpParser\Node\Stmt\Namespace_;
29
+ use PhpParser\Node\Stmt\Nop;
22
30
  use PhpParser\Node\Stmt\Property;
23
31
  use PhpParser\Node\Stmt\TryCatch;
24
- use PhpParser\Node\Stmt\UseUse;
25
- use PhpParser\Node\VarLikeIdentifier;
32
+ use PhpParser\Node\UseItem;
33
+ use PhpParser\NodeVisitor\CommentAnnotatingVisitor;
34
+
35
+ abstract class ParserAbstract implements Parser {
36
+ private const SYMBOL_NONE = -1;
26
37
 
27
- abstract class ParserAbstract implements Parser
28
- {
29
- const SYMBOL_NONE = -1;
38
+ /** @var Lexer Lexer that is used when parsing */
39
+ protected Lexer $lexer;
40
+ /** @var PhpVersion PHP version to target on a best-effort basis */
41
+ protected PhpVersion $phpVersion;
30
42
 
31
43
  /*
32
44
  * The following members will be filled with generated parsing data:
33
45
  */
34
46
 
35
47
  /** @var int Size of $tokenToSymbol map */
36
- protected $tokenToSymbolMapSize;
48
+ protected int $tokenToSymbolMapSize;
37
49
  /** @var int Size of $action table */
38
- protected $actionTableSize;
50
+ protected int $actionTableSize;
39
51
  /** @var int Size of $goto table */
40
- protected $gotoTableSize;
52
+ protected int $gotoTableSize;
41
53
 
42
54
  /** @var int Symbol number signifying an invalid token */
43
- protected $invalidSymbol;
55
+ protected int $invalidSymbol;
44
56
  /** @var int Symbol number of error recovery token */
45
- protected $errorSymbol;
57
+ protected int $errorSymbol;
46
58
  /** @var int Action number signifying default action */
47
- protected $defaultAction;
59
+ protected int $defaultAction;
48
60
  /** @var int Rule number signifying that an unexpected token was encountered */
49
- protected $unexpectedTokenRule;
61
+ protected int $unexpectedTokenRule;
50
62
 
51
- protected $YY2TBLSTATE;
63
+ protected int $YY2TBLSTATE;
52
64
  /** @var int Number of non-leaf states */
53
- protected $numNonLeafStates;
54
-
55
- /** @var int[] Map of lexer tokens to internal symbols */
56
- protected $tokenToSymbol;
65
+ protected int $numNonLeafStates;
66
+
67
+ /** @var int[] Map of PHP token IDs to internal symbols */
68
+ protected array $phpTokenToSymbol;
69
+ /** @var array<int, bool> Map of PHP token IDs to drop */
70
+ protected array $dropTokens;
71
+ /** @var int[] Map of external symbols (static::T_*) to internal symbols */
72
+ protected array $tokenToSymbol;
57
73
  /** @var string[] Map of symbols to their names */
58
- protected $symbolToName;
59
- /** @var array Names of the production rules (only necessary for debugging) */
60
- protected $productions;
74
+ protected array $symbolToName;
75
+ /** @var array<int, string> Names of the production rules (only necessary for debugging) */
76
+ protected array $productions;
61
77
 
62
78
  /** @var int[] Map of states to a displacement into the $action table. The corresponding action for this
63
79
  * state/symbol pair is $action[$actionBase[$state] + $symbol]. If $actionBase[$state] is 0, the
64
80
  * action is defaulted, i.e. $actionDefault[$state] should be used instead. */
65
- protected $actionBase;
81
+ protected array $actionBase;
66
82
  /** @var int[] Table of actions. Indexed according to $actionBase comment. */
67
- protected $action;
83
+ protected array $action;
68
84
  /** @var int[] Table indexed analogously to $action. If $actionCheck[$actionBase[$state] + $symbol] != $symbol
69
85
  * then the action is defaulted, i.e. $actionDefault[$state] should be used instead. */
70
- protected $actionCheck;
86
+ protected array $actionCheck;
71
87
  /** @var int[] Map of states to their default action */
72
- protected $actionDefault;
88
+ protected array $actionDefault;
73
89
  /** @var callable[] Semantic action callbacks */
74
- protected $reduceCallbacks;
90
+ protected array $reduceCallbacks;
75
91
 
76
92
  /** @var int[] Map of non-terminals to a displacement into the $goto table. The corresponding goto state for this
77
93
  * non-terminal/state pair is $goto[$gotoBase[$nonTerminal] + $state] (unless defaulted) */
78
- protected $gotoBase;
94
+ protected array $gotoBase;
79
95
  /** @var int[] Table of states to goto after reduction. Indexed according to $gotoBase comment. */
80
- protected $goto;
96
+ protected array $goto;
81
97
  /** @var int[] Table indexed analogously to $goto. If $gotoCheck[$gotoBase[$nonTerminal] + $state] != $nonTerminal
82
98
  * then the goto state is defaulted, i.e. $gotoDefault[$nonTerminal] should be used. */
83
- protected $gotoCheck;
99
+ protected array $gotoCheck;
84
100
  /** @var int[] Map of non-terminals to the default state to goto after their reduction */
85
- protected $gotoDefault;
101
+ protected array $gotoDefault;
86
102
 
87
103
  /** @var int[] Map of rules to the non-terminal on their left-hand side, i.e. the non-terminal to use for
88
104
  * determining the state to goto after reduction. */
89
- protected $ruleToNonTerminal;
105
+ protected array $ruleToNonTerminal;
90
106
  /** @var int[] Map of rules to the length of their right-hand side, which is the number of elements that have to
91
107
  * be popped from the stack(s) on reduction. */
92
- protected $ruleToLength;
108
+ protected array $ruleToLength;
93
109
 
94
110
  /*
95
111
  * The following members are part of the parser state:
96
112
  */
97
113
 
98
- /** @var Lexer Lexer that is used when parsing */
99
- protected $lexer;
100
114
  /** @var mixed Temporary value containing the result of last semantic action (reduction) */
101
115
  protected $semValue;
102
- /** @var array Semantic value stack (contains values of tokens and semantic action results) */
103
- protected $semStack;
104
- /** @var array[] Start attribute stack */
105
- protected $startAttributeStack;
106
- /** @var array[] End attribute stack */
107
- protected $endAttributeStack;
108
- /** @var array End attributes of last *shifted* token */
109
- protected $endAttributes;
110
- /** @var array Start attributes of last *read* token */
111
- protected $lookaheadStartAttributes;
116
+ /** @var mixed[] Semantic value stack (contains values of tokens and semantic action results) */
117
+ protected array $semStack;
118
+ /** @var int[] Token start position stack */
119
+ protected array $tokenStartStack;
120
+ /** @var int[] Token end position stack */
121
+ protected array $tokenEndStack;
112
122
 
113
123
  /** @var ErrorHandler Error handler */
114
- protected $errorHandler;
124
+ protected ErrorHandler $errorHandler;
115
125
  /** @var int Error state, used to avoid error floods */
116
- protected $errorState;
126
+ protected int $errorState;
127
+
128
+ /** @var \SplObjectStorage<Array_, null>|null Array nodes created during parsing, for postprocessing of empty elements. */
129
+ protected ?\SplObjectStorage $createdArrays;
130
+
131
+ /** @var Token[] Tokens for the current parse */
132
+ protected array $tokens;
133
+ /** @var int Current position in token array */
134
+ protected int $tokenPos;
117
135
 
118
136
  /**
119
137
  * Initialize $reduceCallbacks map.
120
138
  */
121
- abstract protected function initReduceCallbacks();
139
+ abstract protected function initReduceCallbacks(): void;
122
140
 
123
141
  /**
124
142
  * Creates a parser instance.
125
143
  *
126
- * Options: Currently none.
144
+ * Options:
145
+ * * phpVersion: ?PhpVersion,
127
146
  *
128
147
  * @param Lexer $lexer A lexer
129
- * @param array $options Options array.
148
+ * @param PhpVersion $phpVersion PHP version to target, defaults to latest supported. This
149
+ * option is best-effort: Even if specified, parsing will generally assume the latest
150
+ * supported version and only adjust behavior in minor ways, for example by omitting
151
+ * errors in older versions and interpreting type hints as a name or identifier depending
152
+ * on version.
130
153
  */
131
- public function __construct(Lexer $lexer, array $options = []) {
154
+ public function __construct(Lexer $lexer, ?PhpVersion $phpVersion = null) {
132
155
  $this->lexer = $lexer;
133
-
134
- if (isset($options['throwOnError'])) {
135
- throw new \LogicException(
136
- '"throwOnError" is no longer supported, use "errorHandler" instead');
137
- }
156
+ $this->phpVersion = $phpVersion ?? PhpVersion::getNewestSupported();
138
157
 
139
158
  $this->initReduceCallbacks();
159
+ $this->phpTokenToSymbol = $this->createTokenMap();
160
+ $this->dropTokens = array_fill_keys(
161
+ [\T_WHITESPACE, \T_OPEN_TAG, \T_COMMENT, \T_DOC_COMMENT, \T_BAD_CHARACTER], true
162
+ );
140
163
  }
141
164
 
142
165
  /**
@@ -152,36 +175,55 @@ abstract class ParserAbstract implements Parser
152
175
  * @return Node\Stmt[]|null Array of statements (or null non-throwing error handler is used and
153
176
  * the parser was unable to recover from an error).
154
177
  */
155
- public function parse(string $code, ErrorHandler $errorHandler = null) {
156
- $this->errorHandler = $errorHandler ?: new ErrorHandler\Throwing;
178
+ public function parse(string $code, ?ErrorHandler $errorHandler = null): ?array {
179
+ $this->errorHandler = $errorHandler ?: new ErrorHandler\Throwing();
180
+ $this->createdArrays = new \SplObjectStorage();
157
181
 
158
- $this->lexer->startLexing($code, $this->errorHandler);
182
+ $this->tokens = $this->lexer->tokenize($code, $this->errorHandler);
159
183
  $result = $this->doParse();
160
184
 
185
+ // Report errors for any empty elements used inside arrays. This is delayed until after the main parse,
186
+ // because we don't know a priori whether a given array expression will be used in a destructuring context
187
+ // or not.
188
+ foreach ($this->createdArrays as $node) {
189
+ foreach ($node->items as $item) {
190
+ if ($item->value instanceof Expr\Error) {
191
+ $this->errorHandler->handleError(
192
+ new Error('Cannot use empty array elements in arrays', $item->getAttributes()));
193
+ }
194
+ }
195
+ }
196
+
161
197
  // Clear out some of the interior state, so we don't hold onto unnecessary
162
198
  // memory between uses of the parser
163
- $this->startAttributeStack = [];
164
- $this->endAttributeStack = [];
199
+ $this->tokenStartStack = [];
200
+ $this->tokenEndStack = [];
165
201
  $this->semStack = [];
166
202
  $this->semValue = null;
203
+ $this->createdArrays = null;
204
+
205
+ if ($result !== null) {
206
+ $traverser = new NodeTraverser(new CommentAnnotatingVisitor($this->tokens));
207
+ $traverser->traverse($result);
208
+ }
167
209
 
168
210
  return $result;
169
211
  }
170
212
 
171
- protected function doParse() {
213
+ public function getTokens(): array {
214
+ return $this->tokens;
215
+ }
216
+
217
+ /** @return Stmt[]|null */
218
+ protected function doParse(): ?array {
172
219
  // We start off with no lookahead-token
173
220
  $symbol = self::SYMBOL_NONE;
174
-
175
- // The attributes for a node are taken from the first and last token of the node.
176
- // From the first token only the startAttributes are taken and from the last only
177
- // the endAttributes. Both are merged using the array union operator (+).
178
- $startAttributes = [];
179
- $endAttributes = [];
180
- $this->endAttributes = $endAttributes;
221
+ $tokenValue = null;
222
+ $this->tokenPos = -1;
181
223
 
182
224
  // Keep stack of start and end attributes
183
- $this->startAttributeStack = [];
184
- $this->endAttributeStack = [$endAttributes];
225
+ $this->tokenStartStack = [];
226
+ $this->tokenEndStack = [0];
185
227
 
186
228
  // Start off in the initial state and keep a stack of previous states
187
229
  $state = 0;
@@ -202,26 +244,20 @@ abstract class ParserAbstract implements Parser
202
244
  $rule = $this->actionDefault[$state];
203
245
  } else {
204
246
  if ($symbol === self::SYMBOL_NONE) {
205
- // Fetch the next token id from the lexer and fetch additional info by-ref.
206
- // The end attributes are fetched into a temporary variable and only set once the token is really
207
- // shifted (not during read). Otherwise you would sometimes get off-by-one errors, when a rule is
208
- // reduced after a token was read but not yet shifted.
209
- $tokenId = $this->lexer->getNextToken($tokenValue, $startAttributes, $endAttributes);
210
-
211
- // map the lexer token id to the internally used symbols
212
- $symbol = $tokenId >= 0 && $tokenId < $this->tokenToSymbolMapSize
213
- ? $this->tokenToSymbol[$tokenId]
214
- : $this->invalidSymbol;
215
-
216
- if ($symbol === $this->invalidSymbol) {
247
+ do {
248
+ $token = $this->tokens[++$this->tokenPos];
249
+ $tokenId = $token->id;
250
+ } while (isset($this->dropTokens[$tokenId]));
251
+
252
+ // Map the lexer token id to the internally used symbols.
253
+ $tokenValue = $token->text;
254
+ if (!isset($this->phpTokenToSymbol[$tokenId])) {
217
255
  throw new \RangeException(sprintf(
218
256
  'The lexer returned an invalid token (id=%d, value=%s)',
219
257
  $tokenId, $tokenValue
220
258
  ));
221
259
  }
222
-
223
- // Allow productions to access the start attributes of the lookahead token.
224
- $this->lookaheadStartAttributes = $startAttributes;
260
+ $symbol = $this->phpTokenToSymbol[$tokenId];
225
261
 
226
262
  //$this->traceRead($symbol);
227
263
  }
@@ -246,9 +282,8 @@ abstract class ParserAbstract implements Parser
246
282
  ++$stackPos;
247
283
  $stateStack[$stackPos] = $state = $action;
248
284
  $this->semStack[$stackPos] = $tokenValue;
249
- $this->startAttributeStack[$stackPos] = $startAttributes;
250
- $this->endAttributeStack[$stackPos] = $endAttributes;
251
- $this->endAttributes = $endAttributes;
285
+ $this->tokenStartStack[$stackPos] = $this->tokenPos;
286
+ $this->tokenEndStack[$stackPos] = $this->tokenPos;
252
287
  $symbol = self::SYMBOL_NONE;
253
288
 
254
289
  if ($this->errorState) {
@@ -274,15 +309,22 @@ abstract class ParserAbstract implements Parser
274
309
  /* accept */
275
310
  //$this->traceAccept();
276
311
  return $this->semValue;
277
- } elseif ($rule !== $this->unexpectedTokenRule) {
312
+ }
313
+ if ($rule !== $this->unexpectedTokenRule) {
278
314
  /* reduce */
279
315
  //$this->traceReduce($rule);
280
316
 
317
+ $ruleLength = $this->ruleToLength[$rule];
281
318
  try {
282
- $this->reduceCallbacks[$rule]($stackPos);
319
+ $callback = $this->reduceCallbacks[$rule];
320
+ if ($callback !== null) {
321
+ $callback($this, $stackPos);
322
+ } elseif ($ruleLength > 0) {
323
+ $this->semValue = $this->semStack[$stackPos - $ruleLength + 1];
324
+ }
283
325
  } catch (Error $e) {
284
- if (-1 === $e->getStartLine() && isset($startAttributes['startLine'])) {
285
- $e->setStartLine($startAttributes['startLine']);
326
+ if (-1 === $e->getStartLine()) {
327
+ $e->setStartLine($this->tokens[$this->tokenPos]->line);
286
328
  }
287
329
 
288
330
  $this->emitError($e);
@@ -291,8 +333,7 @@ abstract class ParserAbstract implements Parser
291
333
  }
292
334
 
293
335
  /* Goto - shift nonterminal */
294
- $lastEndAttributes = $this->endAttributeStack[$stackPos];
295
- $ruleLength = $this->ruleToLength[$rule];
336
+ $lastTokenEnd = $this->tokenEndStack[$stackPos];
296
337
  $stackPos -= $ruleLength;
297
338
  $nonTerminal = $this->ruleToNonTerminal[$rule];
298
339
  $idx = $this->gotoBase[$nonTerminal] + $stateStack[$stackPos];
@@ -305,18 +346,19 @@ abstract class ParserAbstract implements Parser
305
346
  ++$stackPos;
306
347
  $stateStack[$stackPos] = $state;
307
348
  $this->semStack[$stackPos] = $this->semValue;
308
- $this->endAttributeStack[$stackPos] = $lastEndAttributes;
349
+ $this->tokenEndStack[$stackPos] = $lastTokenEnd;
309
350
  if ($ruleLength === 0) {
310
351
  // Empty productions use the start attributes of the lookahead token.
311
- $this->startAttributeStack[$stackPos] = $this->lookaheadStartAttributes;
352
+ $this->tokenStartStack[$stackPos] = $this->tokenPos;
312
353
  }
313
354
  } else {
314
355
  /* error */
315
356
  switch ($this->errorState) {
316
357
  case 0:
317
358
  $msg = $this->getErrorMessage($symbol, $state);
318
- $this->emitError(new Error($msg, $startAttributes + $endAttributes));
359
+ $this->emitError(new Error($msg, $this->getAttributesForToken($this->tokenPos)));
319
360
  // Break missing intentionally
361
+ // no break
320
362
  case 1:
321
363
  case 2:
322
364
  $this->errorState = 3;
@@ -343,9 +385,8 @@ abstract class ParserAbstract implements Parser
343
385
 
344
386
  // We treat the error symbol as being empty, so we reset the end attributes
345
387
  // to the end attributes of the last non-error symbol
346
- $this->startAttributeStack[$stackPos] = $this->lookaheadStartAttributes;
347
- $this->endAttributeStack[$stackPos] = $this->endAttributeStack[$stackPos - 1];
348
- $this->endAttributes = $this->endAttributeStack[$stackPos - 1];
388
+ $this->tokenStartStack[$stackPos] = $this->tokenPos;
389
+ $this->tokenEndStack[$stackPos] = $this->tokenEndStack[$stackPos - 1];
349
390
  break;
350
391
 
351
392
  case 3:
@@ -372,7 +413,7 @@ abstract class ParserAbstract implements Parser
372
413
  throw new \RuntimeException('Reached end of parser loop');
373
414
  }
374
415
 
375
- protected function emitError(Error $error) {
416
+ protected function emitError(Error $error): void {
376
417
  $this->errorHandler->handleError($error);
377
418
  }
378
419
 
@@ -380,11 +421,11 @@ abstract class ParserAbstract implements Parser
380
421
  * Format error message including expected tokens.
381
422
  *
382
423
  * @param int $symbol Unexpected symbol
383
- * @param int $state State at time of error
424
+ * @param int $state State at time of error
384
425
  *
385
426
  * @return string Formatted error message
386
427
  */
387
- protected function getErrorMessage(int $symbol, int $state) : string {
428
+ protected function getErrorMessage(int $symbol, int $state): string {
388
429
  $expectedString = '';
389
430
  if ($expected = $this->getExpectedTokens($state)) {
390
431
  $expectedString = ', expecting ' . implode(' or ', $expected);
@@ -400,7 +441,7 @@ abstract class ParserAbstract implements Parser
400
441
  *
401
442
  * @return string[] Expected tokens. If too many, an empty array is returned.
402
443
  */
403
- protected function getExpectedTokens(int $state) : array {
444
+ protected function getExpectedTokens(int $state): array {
404
445
  $expected = [];
405
446
 
406
447
  $base = $this->actionBase[$state];
@@ -428,37 +469,79 @@ abstract class ParserAbstract implements Parser
428
469
  return $expected;
429
470
  }
430
471
 
472
+ /**
473
+ * Get attributes for a node with the given start and end token positions.
474
+ *
475
+ * @param int $tokenStartPos Token position the node starts at
476
+ * @param int $tokenEndPos Token position the node ends at
477
+ * @return array<string, mixed> Attributes
478
+ */
479
+ protected function getAttributes(int $tokenStartPos, int $tokenEndPos): array {
480
+ $startToken = $this->tokens[$tokenStartPos];
481
+ $afterEndToken = $this->tokens[$tokenEndPos + 1];
482
+ return [
483
+ 'startLine' => $startToken->line,
484
+ 'startTokenPos' => $tokenStartPos,
485
+ 'startFilePos' => $startToken->pos,
486
+ 'endLine' => $afterEndToken->line,
487
+ 'endTokenPos' => $tokenEndPos,
488
+ 'endFilePos' => $afterEndToken->pos - 1,
489
+ ];
490
+ }
491
+
492
+ /**
493
+ * Get attributes for a single token at the given token position.
494
+ *
495
+ * @return array<string, mixed> Attributes
496
+ */
497
+ protected function getAttributesForToken(int $tokenPos): array {
498
+ if ($tokenPos < \count($this->tokens) - 1) {
499
+ return $this->getAttributes($tokenPos, $tokenPos);
500
+ }
501
+
502
+ // Get attributes for the sentinel token.
503
+ $token = $this->tokens[$tokenPos];
504
+ return [
505
+ 'startLine' => $token->line,
506
+ 'startTokenPos' => $tokenPos,
507
+ 'startFilePos' => $token->pos,
508
+ 'endLine' => $token->line,
509
+ 'endTokenPos' => $tokenPos,
510
+ 'endFilePos' => $token->pos,
511
+ ];
512
+ }
513
+
431
514
  /*
432
515
  * Tracing functions used for debugging the parser.
433
516
  */
434
517
 
435
518
  /*
436
- protected function traceNewState($state, $symbol) {
519
+ protected function traceNewState($state, $symbol): void {
437
520
  echo '% State ' . $state
438
521
  . ', Lookahead ' . ($symbol == self::SYMBOL_NONE ? '--none--' : $this->symbolToName[$symbol]) . "\n";
439
522
  }
440
523
 
441
- protected function traceRead($symbol) {
524
+ protected function traceRead($symbol): void {
442
525
  echo '% Reading ' . $this->symbolToName[$symbol] . "\n";
443
526
  }
444
527
 
445
- protected function traceShift($symbol) {
528
+ protected function traceShift($symbol): void {
446
529
  echo '% Shift ' . $this->symbolToName[$symbol] . "\n";
447
530
  }
448
531
 
449
- protected function traceAccept() {
532
+ protected function traceAccept(): void {
450
533
  echo "% Accepted.\n";
451
534
  }
452
535
 
453
- protected function traceReduce($n) {
536
+ protected function traceReduce($n): void {
454
537
  echo '% Reduce by (' . $n . ') ' . $this->productions[$n] . "\n";
455
538
  }
456
539
 
457
- protected function tracePop($state) {
540
+ protected function tracePop($state): void {
458
541
  echo '% Recovering, uncovered state ' . $state . "\n";
459
542
  }
460
543
 
461
- protected function traceDiscard($symbol) {
544
+ protected function traceDiscard($symbol): void {
462
545
  echo '% Discard ' . $this->symbolToName[$symbol] . "\n";
463
546
  }
464
547
  */
@@ -473,13 +556,14 @@ abstract class ParserAbstract implements Parser
473
556
  * @param Node\Stmt[] $stmts
474
557
  * @return Node\Stmt[]
475
558
  */
476
- protected function handleNamespaces(array $stmts) : array {
559
+ protected function handleNamespaces(array $stmts): array {
477
560
  $hasErrored = false;
478
561
  $style = $this->getNamespacingStyle($stmts);
479
562
  if (null === $style) {
480
563
  // not namespaced, nothing to do
481
564
  return $stmts;
482
- } elseif ('brace' === $style) {
565
+ }
566
+ if ('brace' === $style) {
483
567
  // For braced namespaces we only have to check that there are no invalid statements between the namespaces
484
568
  $afterFirstNamespace = false;
485
569
  foreach ($stmts as $stmt) {
@@ -497,7 +581,7 @@ abstract class ParserAbstract implements Parser
497
581
  } else {
498
582
  // For semicolon namespaces we have to move the statements after a namespace declaration into ->stmts
499
583
  $resultStmts = [];
500
- $targetStmts =& $resultStmts;
584
+ $targetStmts = &$resultStmts;
501
585
  $lastNs = null;
502
586
  foreach ($stmts as $stmt) {
503
587
  if ($stmt instanceof Node\Stmt\Namespace_) {
@@ -506,12 +590,12 @@ abstract class ParserAbstract implements Parser
506
590
  }
507
591
  if ($stmt->stmts === null) {
508
592
  $stmt->stmts = [];
509
- $targetStmts =& $stmt->stmts;
593
+ $targetStmts = &$stmt->stmts;
510
594
  $resultStmts[] = $stmt;
511
595
  } else {
512
596
  // This handles the invalid case of mixed style namespaces
513
597
  $resultStmts[] = $stmt;
514
- $targetStmts =& $resultStmts;
598
+ $targetStmts = &$resultStmts;
515
599
  }
516
600
  $lastNs = $stmt;
517
601
  } elseif ($stmt instanceof Node\Stmt\HaltCompiler) {
@@ -528,7 +612,7 @@ abstract class ParserAbstract implements Parser
528
612
  }
529
613
  }
530
614
 
531
- private function fixupNamespaceAttributes(Node\Stmt\Namespace_ $stmt) {
615
+ private function fixupNamespaceAttributes(Node\Stmt\Namespace_ $stmt): void {
532
616
  // We moved the statements into the namespace node, as such the end of the namespace node
533
617
  // needs to be extended to the end of the statements.
534
618
  if (empty($stmt->stmts)) {
@@ -546,6 +630,22 @@ abstract class ParserAbstract implements Parser
546
630
  }
547
631
  }
548
632
 
633
+ /** @return array<string, mixed> */
634
+ private function getNamespaceErrorAttributes(Namespace_ $node): array {
635
+ $attrs = $node->getAttributes();
636
+ // Adjust end attributes to only cover the "namespace" keyword, not the whole namespace.
637
+ if (isset($attrs['startLine'])) {
638
+ $attrs['endLine'] = $attrs['startLine'];
639
+ }
640
+ if (isset($attrs['startTokenPos'])) {
641
+ $attrs['endTokenPos'] = $attrs['startTokenPos'];
642
+ }
643
+ if (isset($attrs['startFilePos'])) {
644
+ $attrs['endFilePos'] = $attrs['startFilePos'] + \strlen('namespace') - 1;
645
+ }
646
+ return $attrs;
647
+ }
648
+
549
649
  /**
550
650
  * Determine namespacing style (semicolon or brace)
551
651
  *
@@ -553,7 +653,7 @@ abstract class ParserAbstract implements Parser
553
653
  *
554
654
  * @return null|string One of "semicolon", "brace" or null (no namespaces)
555
655
  */
556
- private function getNamespacingStyle(array $stmts) {
656
+ private function getNamespacingStyle(array $stmts): ?string {
557
657
  $style = null;
558
658
  $hasNotAllowedStmts = false;
559
659
  foreach ($stmts as $i => $stmt) {
@@ -564,13 +664,13 @@ abstract class ParserAbstract implements Parser
564
664
  if ($hasNotAllowedStmts) {
565
665
  $this->emitError(new Error(
566
666
  'Namespace declaration statement has to be the very first statement in the script',
567
- $stmt->getLine() // Avoid marking the entire namespace as an error
667
+ $this->getNamespaceErrorAttributes($stmt)
568
668
  ));
569
669
  }
570
670
  } elseif ($style !== $currentStyle) {
571
671
  $this->emitError(new Error(
572
672
  'Cannot mix bracketed namespace declarations with unbracketed namespace declarations',
573
- $stmt->getLine() // Avoid marking the entire namespace as an error
673
+ $this->getNamespaceErrorAttributes($stmt)
574
674
  ));
575
675
  // Treat like semicolon style for namespace normalization
576
676
  return 'semicolon';
@@ -596,82 +696,14 @@ abstract class ParserAbstract implements Parser
596
696
  return $style;
597
697
  }
598
698
 
599
- /**
600
- * Fix up parsing of static property calls in PHP 5.
601
- *
602
- * In PHP 5 A::$b[c][d] and A::$b[c][d]() have very different interpretation. The former is
603
- * interpreted as (A::$b)[c][d], while the latter is the same as A::{$b[c][d]}(). We parse the
604
- * latter as the former initially and this method fixes the AST into the correct form when we
605
- * encounter the "()".
606
- *
607
- * @param Node\Expr\StaticPropertyFetch|Node\Expr\ArrayDimFetch $prop
608
- * @param Node\Arg[] $args
609
- * @param array $attributes
610
- *
611
- * @return Expr\StaticCall
612
- */
613
- protected function fixupPhp5StaticPropCall($prop, array $args, array $attributes) : Expr\StaticCall {
614
- if ($prop instanceof Node\Expr\StaticPropertyFetch) {
615
- $name = $prop->name instanceof VarLikeIdentifier
616
- ? $prop->name->toString() : $prop->name;
617
- $var = new Expr\Variable($name, $prop->name->getAttributes());
618
- return new Expr\StaticCall($prop->class, $var, $args, $attributes);
619
- } elseif ($prop instanceof Node\Expr\ArrayDimFetch) {
620
- $tmp = $prop;
621
- while ($tmp->var instanceof Node\Expr\ArrayDimFetch) {
622
- $tmp = $tmp->var;
623
- }
624
-
625
- /** @var Expr\StaticPropertyFetch $staticProp */
626
- $staticProp = $tmp->var;
627
-
628
- // Set start attributes to attributes of innermost node
629
- $tmp = $prop;
630
- $this->fixupStartAttributes($tmp, $staticProp->name);
631
- while ($tmp->var instanceof Node\Expr\ArrayDimFetch) {
632
- $tmp = $tmp->var;
633
- $this->fixupStartAttributes($tmp, $staticProp->name);
634
- }
635
-
636
- $name = $staticProp->name instanceof VarLikeIdentifier
637
- ? $staticProp->name->toString() : $staticProp->name;
638
- $tmp->var = new Expr\Variable($name, $staticProp->name->getAttributes());
639
- return new Expr\StaticCall($staticProp->class, $prop, $args, $attributes);
640
- } else {
641
- throw new \Exception;
642
- }
643
- }
644
-
645
- protected function fixupStartAttributes(Node $to, Node $from) {
646
- $startAttributes = ['startLine', 'startFilePos', 'startTokenPos'];
647
- foreach ($startAttributes as $startAttribute) {
648
- if ($from->hasAttribute($startAttribute)) {
649
- $to->setAttribute($startAttribute, $from->getAttribute($startAttribute));
650
- }
651
- }
652
- }
653
-
699
+ /** @return Name|Identifier */
654
700
  protected function handleBuiltinTypes(Name $name) {
655
- $builtinTypes = [
656
- 'bool' => true,
657
- 'int' => true,
658
- 'float' => true,
659
- 'string' => true,
660
- 'iterable' => true,
661
- 'void' => true,
662
- 'object' => true,
663
- 'null' => true,
664
- 'false' => true,
665
- 'mixed' => true,
666
- 'never' => true,
667
- ];
668
-
669
701
  if (!$name->isUnqualified()) {
670
702
  return $name;
671
703
  }
672
704
 
673
705
  $lowerName = $name->toLowerString();
674
- if (!isset($builtinTypes[$lowerName])) {
706
+ if (!$this->phpVersion->supportsBuiltinType($lowerName)) {
675
707
  return $name;
676
708
  }
677
709
 
@@ -681,16 +713,15 @@ abstract class ParserAbstract implements Parser
681
713
  /**
682
714
  * Get combined start and end attributes at a stack location
683
715
  *
684
- * @param int $pos Stack location
716
+ * @param int $stackPos Stack location
685
717
  *
686
- * @return array Combined start and end attributes
718
+ * @return array<string, mixed> Combined start and end attributes
687
719
  */
688
- protected function getAttributesAt(int $pos) : array {
689
- return $this->startAttributeStack[$pos] + $this->endAttributeStack[$pos];
720
+ protected function getAttributesAt(int $stackPos): array {
721
+ return $this->getAttributes($this->tokenStartStack[$stackPos], $this->tokenEndStack[$stackPos]);
690
722
  }
691
723
 
692
- protected function getFloatCastKind(string $cast): int
693
- {
724
+ protected function getFloatCastKind(string $cast): int {
694
725
  $cast = strtolower($cast);
695
726
  if (strpos($cast, 'float') !== false) {
696
727
  return Double::KIND_FLOAT;
@@ -703,23 +734,24 @@ abstract class ParserAbstract implements Parser
703
734
  return Double::KIND_DOUBLE;
704
735
  }
705
736
 
706
- protected function parseLNumber($str, $attributes, $allowInvalidOctal = false) {
737
+ /** @param array<string, mixed> $attributes */
738
+ protected function parseLNumber(string $str, array $attributes, bool $allowInvalidOctal = false): Int_ {
707
739
  try {
708
- return LNumber::fromString($str, $attributes, $allowInvalidOctal);
740
+ return Int_::fromString($str, $attributes, $allowInvalidOctal);
709
741
  } catch (Error $error) {
710
742
  $this->emitError($error);
711
743
  // Use dummy value
712
- return new LNumber(0, $attributes);
744
+ return new Int_(0, $attributes);
713
745
  }
714
746
  }
715
747
 
716
748
  /**
717
749
  * Parse a T_NUM_STRING token into either an integer or string node.
718
750
  *
719
- * @param string $str Number string
720
- * @param array $attributes Attributes
751
+ * @param string $str Number string
752
+ * @param array<string, mixed> $attributes Attributes
721
753
  *
722
- * @return LNumber|String_ Integer or string node.
754
+ * @return Int_|String_ Integer or string node.
723
755
  */
724
756
  protected function parseNumString(string $str, array $attributes) {
725
757
  if (!preg_match('/^(?:0|-?[1-9][0-9]*)$/', $str)) {
@@ -731,13 +763,14 @@ abstract class ParserAbstract implements Parser
731
763
  return new String_($str, $attributes);
732
764
  }
733
765
 
734
- return new LNumber($num, $attributes);
766
+ return new Int_($num, $attributes);
735
767
  }
736
768
 
769
+ /** @param array<string, mixed> $attributes */
737
770
  protected function stripIndentation(
738
771
  string $string, int $indentLen, string $indentChar,
739
772
  bool $newlineAtStart, bool $newlineAtEnd, array $attributes
740
- ) {
773
+ ): string {
741
774
  if ($indentLen === 0) {
742
775
  return $string;
743
776
  }
@@ -766,10 +799,15 @@ abstract class ParserAbstract implements Parser
766
799
  );
767
800
  }
768
801
 
802
+ /**
803
+ * @param string|(Expr|InterpolatedStringPart)[] $contents
804
+ * @param array<string, mixed> $attributes
805
+ * @param array<string, mixed> $endTokenAttributes
806
+ */
769
807
  protected function parseDocString(
770
808
  string $startToken, $contents, string $endToken,
771
809
  array $attributes, array $endTokenAttributes, bool $parseUnicodeEscape
772
- ) {
810
+ ): Expr {
773
811
  $kind = strpos($startToken, "'") === false
774
812
  ? String_::KIND_HEREDOC : String_::KIND_NOWDOC;
775
813
 
@@ -803,6 +841,7 @@ abstract class ParserAbstract implements Parser
803
841
 
804
842
  if (\is_string($contents)) {
805
843
  if ($contents === '') {
844
+ $attributes['rawValue'] = $contents;
806
845
  return new String_('', $attributes);
807
846
  }
808
847
 
@@ -810,6 +849,7 @@ abstract class ParserAbstract implements Parser
810
849
  $contents, $indentLen, $indentChar, true, true, $attributes
811
850
  );
812
851
  $contents = preg_replace('~(\r\n|\n|\r)\z~', '', $contents);
852
+ $attributes['rawValue'] = $contents;
813
853
 
814
854
  if ($kind === String_::KIND_HEREDOC) {
815
855
  $contents = String_::parseEscapeSequences($contents, null, $parseUnicodeEscape);
@@ -818,7 +858,7 @@ abstract class ParserAbstract implements Parser
818
858
  return new String_($contents, $attributes);
819
859
  } else {
820
860
  assert(count($contents) > 0);
821
- if (!$contents[0] instanceof Node\Scalar\EncapsedStringPart) {
861
+ if (!$contents[0] instanceof Node\InterpolatedStringPart) {
822
862
  // If there is no leading encapsed string part, pretend there is an empty one
823
863
  $this->stripIndentation(
824
864
  '', $indentLen, $indentChar, true, false, $contents[0]->getAttributes()
@@ -827,65 +867,175 @@ abstract class ParserAbstract implements Parser
827
867
 
828
868
  $newContents = [];
829
869
  foreach ($contents as $i => $part) {
830
- if ($part instanceof Node\Scalar\EncapsedStringPart) {
870
+ if ($part instanceof Node\InterpolatedStringPart) {
831
871
  $isLast = $i === \count($contents) - 1;
832
872
  $part->value = $this->stripIndentation(
833
873
  $part->value, $indentLen, $indentChar,
834
874
  $i === 0, $isLast, $part->getAttributes()
835
875
  );
836
- $part->value = String_::parseEscapeSequences($part->value, null, $parseUnicodeEscape);
837
876
  if ($isLast) {
838
877
  $part->value = preg_replace('~(\r\n|\n|\r)\z~', '', $part->value);
839
878
  }
879
+ $part->setAttribute('rawValue', $part->value);
880
+ $part->value = String_::parseEscapeSequences($part->value, null, $parseUnicodeEscape);
840
881
  if ('' === $part->value) {
841
882
  continue;
842
883
  }
843
884
  }
844
885
  $newContents[] = $part;
845
886
  }
846
- return new Encapsed($newContents, $attributes);
887
+ return new InterpolatedString($newContents, $attributes);
847
888
  }
848
889
  }
849
890
 
891
+ protected function createCommentFromToken(Token $token, int $tokenPos): Comment {
892
+ assert($token->id === \T_COMMENT || $token->id == \T_DOC_COMMENT);
893
+ return \T_DOC_COMMENT === $token->id
894
+ ? new Comment\Doc($token->text, $token->line, $token->pos, $tokenPos,
895
+ $token->getEndLine(), $token->getEndPos() - 1, $tokenPos)
896
+ : new Comment($token->text, $token->line, $token->pos, $tokenPos,
897
+ $token->getEndLine(), $token->getEndPos() - 1, $tokenPos);
898
+ }
899
+
850
900
  /**
851
- * Create attributes for a zero-length common-capturing nop.
852
- *
853
- * @param Comment[] $comments
854
- * @return array
901
+ * Get last comment before the given token position, if any
855
902
  */
856
- protected function createCommentNopAttributes(array $comments) {
857
- $comment = $comments[count($comments) - 1];
903
+ protected function getCommentBeforeToken(int $tokenPos): ?Comment {
904
+ while (--$tokenPos >= 0) {
905
+ $token = $this->tokens[$tokenPos];
906
+ if (!isset($this->dropTokens[$token->id])) {
907
+ break;
908
+ }
909
+
910
+ if ($token->id === \T_COMMENT || $token->id === \T_DOC_COMMENT) {
911
+ return $this->createCommentFromToken($token, $tokenPos);
912
+ }
913
+ }
914
+ return null;
915
+ }
916
+
917
+ /**
918
+ * Create a zero-length nop to capture preceding comments, if any.
919
+ */
920
+ protected function maybeCreateZeroLengthNop(int $tokenPos): ?Nop {
921
+ $comment = $this->getCommentBeforeToken($tokenPos);
922
+ if ($comment === null) {
923
+ return null;
924
+ }
925
+
858
926
  $commentEndLine = $comment->getEndLine();
859
927
  $commentEndFilePos = $comment->getEndFilePos();
860
928
  $commentEndTokenPos = $comment->getEndTokenPos();
929
+ $attributes = [
930
+ 'startLine' => $commentEndLine,
931
+ 'endLine' => $commentEndLine,
932
+ 'startFilePos' => $commentEndFilePos + 1,
933
+ 'endFilePos' => $commentEndFilePos,
934
+ 'startTokenPos' => $commentEndTokenPos + 1,
935
+ 'endTokenPos' => $commentEndTokenPos,
936
+ ];
937
+ return new Nop($attributes);
938
+ }
861
939
 
862
- $attributes = ['comments' => $comments];
863
- if (-1 !== $commentEndLine) {
864
- $attributes['startLine'] = $commentEndLine;
865
- $attributes['endLine'] = $commentEndLine;
940
+ protected function maybeCreateNop(int $tokenStartPos, int $tokenEndPos): ?Nop {
941
+ if ($this->getCommentBeforeToken($tokenStartPos) === null) {
942
+ return null;
866
943
  }
867
- if (-1 !== $commentEndFilePos) {
868
- $attributes['startFilePos'] = $commentEndFilePos + 1;
869
- $attributes['endFilePos'] = $commentEndFilePos;
944
+ return new Nop($this->getAttributes($tokenStartPos, $tokenEndPos));
945
+ }
946
+
947
+ protected function handleHaltCompiler(): string {
948
+ // Prevent the lexer from returning any further tokens.
949
+ $nextToken = $this->tokens[$this->tokenPos + 1];
950
+ $this->tokenPos = \count($this->tokens) - 2;
951
+
952
+ // Return text after __halt_compiler.
953
+ return $nextToken->id === \T_INLINE_HTML ? $nextToken->text : '';
954
+ }
955
+
956
+ protected function inlineHtmlHasLeadingNewline(int $stackPos): bool {
957
+ $tokenPos = $this->tokenStartStack[$stackPos];
958
+ $token = $this->tokens[$tokenPos];
959
+ assert($token->id == \T_INLINE_HTML);
960
+ if ($tokenPos > 0) {
961
+ $prevToken = $this->tokens[$tokenPos - 1];
962
+ assert($prevToken->id == \T_CLOSE_TAG);
963
+ return false !== strpos($prevToken->text, "\n")
964
+ || false !== strpos($prevToken->text, "\r");
870
965
  }
871
- if (-1 !== $commentEndTokenPos) {
872
- $attributes['startTokenPos'] = $commentEndTokenPos + 1;
873
- $attributes['endTokenPos'] = $commentEndTokenPos;
966
+ return true;
967
+ }
968
+
969
+ /**
970
+ * @return array<string, mixed>
971
+ */
972
+ protected function createEmptyElemAttributes(int $tokenPos): array {
973
+ return $this->getAttributesForToken($tokenPos);
974
+ }
975
+
976
+ protected function fixupArrayDestructuring(Array_ $node): Expr\List_ {
977
+ $this->createdArrays->detach($node);
978
+ return new Expr\List_(array_map(function (Node\ArrayItem $item) {
979
+ if ($item->value instanceof Expr\Error) {
980
+ // We used Error as a placeholder for empty elements, which are legal for destructuring.
981
+ return null;
982
+ }
983
+ if ($item->value instanceof Array_) {
984
+ return new Node\ArrayItem(
985
+ $this->fixupArrayDestructuring($item->value),
986
+ $item->key, $item->byRef, $item->getAttributes());
987
+ }
988
+ return $item;
989
+ }, $node->items), ['kind' => Expr\List_::KIND_ARRAY] + $node->getAttributes());
990
+ }
991
+
992
+ protected function postprocessList(Expr\List_ $node): void {
993
+ foreach ($node->items as $i => $item) {
994
+ if ($item->value instanceof Expr\Error) {
995
+ // We used Error as a placeholder for empty elements, which are legal for destructuring.
996
+ $node->items[$i] = null;
997
+ }
998
+ }
999
+ }
1000
+
1001
+ /** @param ElseIf_|Else_ $node */
1002
+ protected function fixupAlternativeElse($node): void {
1003
+ // Make sure a trailing nop statement carrying comments is part of the node.
1004
+ $numStmts = \count($node->stmts);
1005
+ if ($numStmts !== 0 && $node->stmts[$numStmts - 1] instanceof Nop) {
1006
+ $nopAttrs = $node->stmts[$numStmts - 1]->getAttributes();
1007
+ if (isset($nopAttrs['endLine'])) {
1008
+ $node->setAttribute('endLine', $nopAttrs['endLine']);
1009
+ }
1010
+ if (isset($nopAttrs['endFilePos'])) {
1011
+ $node->setAttribute('endFilePos', $nopAttrs['endFilePos']);
1012
+ }
1013
+ if (isset($nopAttrs['endTokenPos'])) {
1014
+ $node->setAttribute('endTokenPos', $nopAttrs['endTokenPos']);
1015
+ }
1016
+ }
1017
+ }
1018
+
1019
+ protected function checkClassModifier(int $a, int $b, int $modifierPos): void {
1020
+ try {
1021
+ Modifiers::verifyClassModifier($a, $b);
1022
+ } catch (Error $error) {
1023
+ $error->setAttributes($this->getAttributesAt($modifierPos));
1024
+ $this->emitError($error);
874
1025
  }
875
- return $attributes;
876
1026
  }
877
1027
 
878
- protected function checkModifier($a, $b, $modifierPos) {
1028
+ protected function checkModifier(int $a, int $b, int $modifierPos): void {
879
1029
  // Jumping through some hoops here because verifyModifier() is also used elsewhere
880
1030
  try {
881
- Class_::verifyModifier($a, $b);
1031
+ Modifiers::verifyModifier($a, $b);
882
1032
  } catch (Error $error) {
883
1033
  $error->setAttributes($this->getAttributesAt($modifierPos));
884
1034
  $this->emitError($error);
885
1035
  }
886
1036
  }
887
1037
 
888
- protected function checkParam(Param $node) {
1038
+ protected function checkParam(Param $node): void {
889
1039
  if ($node->variadic && null !== $node->default) {
890
1040
  $this->emitError(new Error(
891
1041
  'Variadic parameter cannot have a default value',
@@ -894,7 +1044,7 @@ abstract class ParserAbstract implements Parser
894
1044
  }
895
1045
  }
896
1046
 
897
- protected function checkTryCatch(TryCatch $node) {
1047
+ protected function checkTryCatch(TryCatch $node): void {
898
1048
  if (empty($node->catches) && null === $node->finally) {
899
1049
  $this->emitError(new Error(
900
1050
  'Cannot use try without catch or finally', $node->getAttributes()
@@ -902,7 +1052,7 @@ abstract class ParserAbstract implements Parser
902
1052
  }
903
1053
  }
904
1054
 
905
- protected function checkNamespace(Namespace_ $node) {
1055
+ protected function checkNamespace(Namespace_ $node): void {
906
1056
  if (null !== $node->stmts) {
907
1057
  foreach ($node->stmts as $stmt) {
908
1058
  if ($stmt instanceof Namespace_) {
@@ -914,7 +1064,7 @@ abstract class ParserAbstract implements Parser
914
1064
  }
915
1065
  }
916
1066
 
917
- private function checkClassName($name, $namePos) {
1067
+ private function checkClassName(?Identifier $name, int $namePos): void {
918
1068
  if (null !== $name && $name->isSpecialClassName()) {
919
1069
  $this->emitError(new Error(
920
1070
  sprintf('Cannot use \'%s\' as class name as it is reserved', $name),
@@ -923,7 +1073,8 @@ abstract class ParserAbstract implements Parser
923
1073
  }
924
1074
  }
925
1075
 
926
- private function checkImplementedInterfaces(array $interfaces) {
1076
+ /** @param Name[] $interfaces */
1077
+ private function checkImplementedInterfaces(array $interfaces): void {
927
1078
  foreach ($interfaces as $interface) {
928
1079
  if ($interface->isSpecialClassName()) {
929
1080
  $this->emitError(new Error(
@@ -934,7 +1085,7 @@ abstract class ParserAbstract implements Parser
934
1085
  }
935
1086
  }
936
1087
 
937
- protected function checkClass(Class_ $node, $namePos) {
1088
+ protected function checkClass(Class_ $node, int $namePos): void {
938
1089
  $this->checkClassName($node->name, $namePos);
939
1090
 
940
1091
  if ($node->extends && $node->extends->isSpecialClassName()) {
@@ -947,18 +1098,18 @@ abstract class ParserAbstract implements Parser
947
1098
  $this->checkImplementedInterfaces($node->implements);
948
1099
  }
949
1100
 
950
- protected function checkInterface(Interface_ $node, $namePos) {
1101
+ protected function checkInterface(Interface_ $node, int $namePos): void {
951
1102
  $this->checkClassName($node->name, $namePos);
952
1103
  $this->checkImplementedInterfaces($node->extends);
953
1104
  }
954
1105
 
955
- protected function checkEnum(Enum_ $node, $namePos) {
1106
+ protected function checkEnum(Enum_ $node, int $namePos): void {
956
1107
  $this->checkClassName($node->name, $namePos);
957
1108
  $this->checkImplementedInterfaces($node->implements);
958
1109
  }
959
1110
 
960
- protected function checkClassMethod(ClassMethod $node, $modifierPos) {
961
- if ($node->flags & Class_::MODIFIER_STATIC) {
1111
+ protected function checkClassMethod(ClassMethod $node, int $modifierPos): void {
1112
+ if ($node->flags & Modifiers::STATIC) {
962
1113
  switch ($node->name->toLowerString()) {
963
1114
  case '__construct':
964
1115
  $this->emitError(new Error(
@@ -977,39 +1128,45 @@ abstract class ParserAbstract implements Parser
977
1128
  break;
978
1129
  }
979
1130
  }
1131
+
1132
+ if ($node->flags & Modifiers::READONLY) {
1133
+ $this->emitError(new Error(
1134
+ sprintf('Method %s() cannot be readonly', $node->name),
1135
+ $this->getAttributesAt($modifierPos)));
1136
+ }
980
1137
  }
981
1138
 
982
- protected function checkClassConst(ClassConst $node, $modifierPos) {
983
- if ($node->flags & Class_::MODIFIER_STATIC) {
1139
+ protected function checkClassConst(ClassConst $node, int $modifierPos): void {
1140
+ if ($node->flags & Modifiers::STATIC) {
984
1141
  $this->emitError(new Error(
985
1142
  "Cannot use 'static' as constant modifier",
986
1143
  $this->getAttributesAt($modifierPos)));
987
1144
  }
988
- if ($node->flags & Class_::MODIFIER_ABSTRACT) {
1145
+ if ($node->flags & Modifiers::ABSTRACT) {
989
1146
  $this->emitError(new Error(
990
1147
  "Cannot use 'abstract' as constant modifier",
991
1148
  $this->getAttributesAt($modifierPos)));
992
1149
  }
993
- if ($node->flags & Class_::MODIFIER_FINAL) {
1150
+ if ($node->flags & Modifiers::READONLY) {
994
1151
  $this->emitError(new Error(
995
- "Cannot use 'final' as constant modifier",
1152
+ "Cannot use 'readonly' as constant modifier",
996
1153
  $this->getAttributesAt($modifierPos)));
997
1154
  }
998
1155
  }
999
1156
 
1000
- protected function checkProperty(Property $node, $modifierPos) {
1001
- if ($node->flags & Class_::MODIFIER_ABSTRACT) {
1157
+ protected function checkProperty(Property $node, int $modifierPos): void {
1158
+ if ($node->flags & Modifiers::ABSTRACT) {
1002
1159
  $this->emitError(new Error('Properties cannot be declared abstract',
1003
1160
  $this->getAttributesAt($modifierPos)));
1004
1161
  }
1005
1162
 
1006
- if ($node->flags & Class_::MODIFIER_FINAL) {
1163
+ if ($node->flags & Modifiers::FINAL) {
1007
1164
  $this->emitError(new Error('Properties cannot be declared final',
1008
1165
  $this->getAttributesAt($modifierPos)));
1009
1166
  }
1010
1167
  }
1011
1168
 
1012
- protected function checkUseUse(UseUse $node, $namePos) {
1169
+ protected function checkUseUse(UseItem $node, int $namePos): void {
1013
1170
  if ($node->alias && $node->alias->isSpecialClassName()) {
1014
1171
  $this->emitError(new Error(
1015
1172
  sprintf(
@@ -1020,4 +1177,65 @@ abstract class ParserAbstract implements Parser
1020
1177
  ));
1021
1178
  }
1022
1179
  }
1180
+
1181
+ /**
1182
+ * Creates the token map.
1183
+ *
1184
+ * The token map maps the PHP internal token identifiers
1185
+ * to the identifiers used by the Parser. Additionally it
1186
+ * maps T_OPEN_TAG_WITH_ECHO to T_ECHO and T_CLOSE_TAG to ';'.
1187
+ *
1188
+ * @return array<int, int> The token map
1189
+ */
1190
+ protected function createTokenMap(): array {
1191
+ $tokenMap = [];
1192
+
1193
+ for ($i = 0; $i < 1000; ++$i) {
1194
+ if ($i < 256) {
1195
+ // Single-char tokens use an identity mapping.
1196
+ $tokenMap[$i] = $i;
1197
+ } elseif (\T_DOUBLE_COLON === $i) {
1198
+ // T_DOUBLE_COLON is equivalent to T_PAAMAYIM_NEKUDOTAYIM
1199
+ $tokenMap[$i] = static::T_PAAMAYIM_NEKUDOTAYIM;
1200
+ } elseif (\T_OPEN_TAG_WITH_ECHO === $i) {
1201
+ // T_OPEN_TAG_WITH_ECHO with dropped T_OPEN_TAG results in T_ECHO
1202
+ $tokenMap[$i] = static::T_ECHO;
1203
+ } elseif (\T_CLOSE_TAG === $i) {
1204
+ // T_CLOSE_TAG is equivalent to ';'
1205
+ $tokenMap[$i] = ord(';');
1206
+ } elseif ('UNKNOWN' !== $name = token_name($i)) {
1207
+ if (defined($name = static::class . '::' . $name)) {
1208
+ // Other tokens can be mapped directly
1209
+ $tokenMap[$i] = constant($name);
1210
+ }
1211
+ }
1212
+ }
1213
+
1214
+ // Assign tokens for which we define compatibility constants, as token_name() does not know them.
1215
+ $tokenMap[\T_FN] = static::T_FN;
1216
+ $tokenMap[\T_COALESCE_EQUAL] = static::T_COALESCE_EQUAL;
1217
+ $tokenMap[\T_NAME_QUALIFIED] = static::T_NAME_QUALIFIED;
1218
+ $tokenMap[\T_NAME_FULLY_QUALIFIED] = static::T_NAME_FULLY_QUALIFIED;
1219
+ $tokenMap[\T_NAME_RELATIVE] = static::T_NAME_RELATIVE;
1220
+ $tokenMap[\T_MATCH] = static::T_MATCH;
1221
+ $tokenMap[\T_NULLSAFE_OBJECT_OPERATOR] = static::T_NULLSAFE_OBJECT_OPERATOR;
1222
+ $tokenMap[\T_ATTRIBUTE] = static::T_ATTRIBUTE;
1223
+ $tokenMap[\T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG] = static::T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG;
1224
+ $tokenMap[\T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG] = static::T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG;
1225
+ $tokenMap[\T_ENUM] = static::T_ENUM;
1226
+ $tokenMap[\T_READONLY] = static::T_READONLY;
1227
+
1228
+ // We have create a map from PHP token IDs to external symbol IDs.
1229
+ // Now map them to the internal symbol ID.
1230
+ $fullTokenMap = [];
1231
+ foreach ($tokenMap as $phpToken => $extSymbol) {
1232
+ $intSymbol = $this->tokenToSymbol[$extSymbol];
1233
+ if ($intSymbol === $this->invalidSymbol) {
1234
+ continue;
1235
+ }
1236
+ $fullTokenMap[$phpToken] = $intSymbol;
1237
+ }
1238
+
1239
+ return $fullTokenMap;
1240
+ }
1023
1241
  }