@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
@@ -3,160 +3,200 @@
3
3
  namespace PhpParser;
4
4
 
5
5
  use PhpParser\Internal\DiffElem;
6
+ use PhpParser\Internal\Differ;
6
7
  use PhpParser\Internal\PrintableNewAnonClassNode;
7
8
  use PhpParser\Internal\TokenStream;
9
+ use PhpParser\Node\AttributeGroup;
8
10
  use PhpParser\Node\Expr;
9
11
  use PhpParser\Node\Expr\AssignOp;
10
12
  use PhpParser\Node\Expr\BinaryOp;
11
13
  use PhpParser\Node\Expr\Cast;
14
+ use PhpParser\Node\IntersectionType;
15
+ use PhpParser\Node\MatchArm;
16
+ use PhpParser\Node\Param;
12
17
  use PhpParser\Node\Scalar;
13
18
  use PhpParser\Node\Stmt;
14
-
15
- abstract class PrettyPrinterAbstract
16
- {
17
- const FIXUP_PREC_LEFT = 0; // LHS operand affected by precedence
18
- const FIXUP_PREC_RIGHT = 1; // RHS operand affected by precedence
19
- const FIXUP_CALL_LHS = 2; // LHS of call
20
- const FIXUP_DEREF_LHS = 3; // LHS of dereferencing operation
21
- const FIXUP_BRACED_NAME = 4; // Name operand that may require bracing
22
- const FIXUP_VAR_BRACED_NAME = 5; // Name operand that may require ${} bracing
23
- const FIXUP_ENCAPSED = 6; // Encapsed string part
24
-
25
- protected $precedenceMap = [
26
- // [precedence, associativity]
27
- // where for precedence -1 is %left, 0 is %nonassoc and 1 is %right
28
- BinaryOp\Pow::class => [ 0, 1],
29
- Expr\BitwiseNot::class => [ 10, 1],
30
- Expr\PreInc::class => [ 10, 1],
31
- Expr\PreDec::class => [ 10, 1],
32
- Expr\PostInc::class => [ 10, -1],
33
- Expr\PostDec::class => [ 10, -1],
34
- Expr\UnaryPlus::class => [ 10, 1],
35
- Expr\UnaryMinus::class => [ 10, 1],
36
- Cast\Int_::class => [ 10, 1],
37
- Cast\Double::class => [ 10, 1],
38
- Cast\String_::class => [ 10, 1],
39
- Cast\Array_::class => [ 10, 1],
40
- Cast\Object_::class => [ 10, 1],
41
- Cast\Bool_::class => [ 10, 1],
42
- Cast\Unset_::class => [ 10, 1],
43
- Expr\ErrorSuppress::class => [ 10, 1],
44
- Expr\Instanceof_::class => [ 20, 0],
45
- Expr\BooleanNot::class => [ 30, 1],
46
- BinaryOp\Mul::class => [ 40, -1],
47
- BinaryOp\Div::class => [ 40, -1],
48
- BinaryOp\Mod::class => [ 40, -1],
49
- BinaryOp\Plus::class => [ 50, -1],
50
- BinaryOp\Minus::class => [ 50, -1],
51
- BinaryOp\Concat::class => [ 50, -1],
52
- BinaryOp\ShiftLeft::class => [ 60, -1],
53
- BinaryOp\ShiftRight::class => [ 60, -1],
54
- BinaryOp\Smaller::class => [ 70, 0],
55
- BinaryOp\SmallerOrEqual::class => [ 70, 0],
56
- BinaryOp\Greater::class => [ 70, 0],
57
- BinaryOp\GreaterOrEqual::class => [ 70, 0],
58
- BinaryOp\Equal::class => [ 80, 0],
59
- BinaryOp\NotEqual::class => [ 80, 0],
60
- BinaryOp\Identical::class => [ 80, 0],
61
- BinaryOp\NotIdentical::class => [ 80, 0],
62
- BinaryOp\Spaceship::class => [ 80, 0],
63
- BinaryOp\BitwiseAnd::class => [ 90, -1],
64
- BinaryOp\BitwiseXor::class => [100, -1],
65
- BinaryOp\BitwiseOr::class => [110, -1],
66
- BinaryOp\BooleanAnd::class => [120, -1],
67
- BinaryOp\BooleanOr::class => [130, -1],
68
- BinaryOp\Coalesce::class => [140, 1],
69
- Expr\Ternary::class => [150, 0],
70
- // parser uses %left for assignments, but they really behave as %right
71
- Expr\Assign::class => [160, 1],
72
- Expr\AssignRef::class => [160, 1],
73
- AssignOp\Plus::class => [160, 1],
74
- AssignOp\Minus::class => [160, 1],
75
- AssignOp\Mul::class => [160, 1],
76
- AssignOp\Div::class => [160, 1],
77
- AssignOp\Concat::class => [160, 1],
78
- AssignOp\Mod::class => [160, 1],
79
- AssignOp\BitwiseAnd::class => [160, 1],
80
- AssignOp\BitwiseOr::class => [160, 1],
81
- AssignOp\BitwiseXor::class => [160, 1],
82
- AssignOp\ShiftLeft::class => [160, 1],
83
- AssignOp\ShiftRight::class => [160, 1],
84
- AssignOp\Pow::class => [160, 1],
85
- AssignOp\Coalesce::class => [160, 1],
86
- Expr\YieldFrom::class => [165, 1],
87
- Expr\Print_::class => [168, 1],
88
- BinaryOp\LogicalAnd::class => [170, -1],
89
- BinaryOp\LogicalXor::class => [180, -1],
90
- BinaryOp\LogicalOr::class => [190, -1],
91
- Expr\Include_::class => [200, -1],
19
+ use PhpParser\Node\UnionType;
20
+
21
+ abstract class PrettyPrinterAbstract implements PrettyPrinter {
22
+ protected const FIXUP_PREC_LEFT = 0; // LHS operand affected by precedence
23
+ protected const FIXUP_PREC_RIGHT = 1; // RHS operand affected by precedence
24
+ protected const FIXUP_PREC_UNARY = 2; // Only operand affected by precedence
25
+ protected const FIXUP_CALL_LHS = 3; // LHS of call
26
+ protected const FIXUP_DEREF_LHS = 4; // LHS of dereferencing operation
27
+ protected const FIXUP_STATIC_DEREF_LHS = 5; // LHS of static dereferencing operation
28
+ protected const FIXUP_BRACED_NAME = 6; // Name operand that may require bracing
29
+ protected const FIXUP_VAR_BRACED_NAME = 7; // Name operand that may require ${} bracing
30
+ protected const FIXUP_ENCAPSED = 8; // Encapsed string part
31
+ protected const FIXUP_NEW = 9; // New/instanceof operand
32
+
33
+ protected const MAX_PRECEDENCE = 1000;
34
+
35
+ /** @var array<class-string, array{int, int, int}> */
36
+ protected array $precedenceMap = [
37
+ // [precedence, precedenceLHS, precedenceRHS]
38
+ // Where the latter two are the precedences to use for the LHS and RHS of a binary operator,
39
+ // where 1 is added to one of the sides depending on associativity. This information is not
40
+ // used for unary operators and set to -1.
41
+ Expr\Clone_::class => [-10, 0, 1],
42
+ BinaryOp\Pow::class => [ 0, 0, 1],
43
+ Expr\BitwiseNot::class => [ 10, -1, -1],
44
+ Expr\UnaryPlus::class => [ 10, -1, -1],
45
+ Expr\UnaryMinus::class => [ 10, -1, -1],
46
+ Cast\Int_::class => [ 10, -1, -1],
47
+ Cast\Double::class => [ 10, -1, -1],
48
+ Cast\String_::class => [ 10, -1, -1],
49
+ Cast\Array_::class => [ 10, -1, -1],
50
+ Cast\Object_::class => [ 10, -1, -1],
51
+ Cast\Bool_::class => [ 10, -1, -1],
52
+ Cast\Unset_::class => [ 10, -1, -1],
53
+ Expr\ErrorSuppress::class => [ 10, -1, -1],
54
+ Expr\Instanceof_::class => [ 20, -1, -1],
55
+ Expr\BooleanNot::class => [ 30, -1, -1],
56
+ BinaryOp\Mul::class => [ 40, 41, 40],
57
+ BinaryOp\Div::class => [ 40, 41, 40],
58
+ BinaryOp\Mod::class => [ 40, 41, 40],
59
+ BinaryOp\Plus::class => [ 50, 51, 50],
60
+ BinaryOp\Minus::class => [ 50, 51, 50],
61
+ BinaryOp\Concat::class => [ 50, 51, 50],
62
+ BinaryOp\ShiftLeft::class => [ 60, 61, 60],
63
+ BinaryOp\ShiftRight::class => [ 60, 61, 60],
64
+ BinaryOp\Smaller::class => [ 70, 70, 70],
65
+ BinaryOp\SmallerOrEqual::class => [ 70, 70, 70],
66
+ BinaryOp\Greater::class => [ 70, 70, 70],
67
+ BinaryOp\GreaterOrEqual::class => [ 70, 70, 70],
68
+ BinaryOp\Equal::class => [ 80, 80, 80],
69
+ BinaryOp\NotEqual::class => [ 80, 80, 80],
70
+ BinaryOp\Identical::class => [ 80, 80, 80],
71
+ BinaryOp\NotIdentical::class => [ 80, 80, 80],
72
+ BinaryOp\Spaceship::class => [ 80, 80, 80],
73
+ BinaryOp\BitwiseAnd::class => [ 90, 91, 90],
74
+ BinaryOp\BitwiseXor::class => [100, 101, 100],
75
+ BinaryOp\BitwiseOr::class => [110, 111, 110],
76
+ BinaryOp\BooleanAnd::class => [120, 121, 120],
77
+ BinaryOp\BooleanOr::class => [130, 131, 130],
78
+ BinaryOp\Coalesce::class => [140, 140, 141],
79
+ Expr\Ternary::class => [150, -1, -1],
80
+ Expr\Assign::class => [160, -1, -1],
81
+ Expr\AssignRef::class => [160, -1, -1],
82
+ AssignOp\Plus::class => [160, -1, -1],
83
+ AssignOp\Minus::class => [160, -1, -1],
84
+ AssignOp\Mul::class => [160, -1, -1],
85
+ AssignOp\Div::class => [160, -1, -1],
86
+ AssignOp\Concat::class => [160, -1, -1],
87
+ AssignOp\Mod::class => [160, -1, -1],
88
+ AssignOp\BitwiseAnd::class => [160, -1, -1],
89
+ AssignOp\BitwiseOr::class => [160, -1, -1],
90
+ AssignOp\BitwiseXor::class => [160, -1, -1],
91
+ AssignOp\ShiftLeft::class => [160, -1, -1],
92
+ AssignOp\ShiftRight::class => [160, -1, -1],
93
+ AssignOp\Pow::class => [160, -1, -1],
94
+ AssignOp\Coalesce::class => [160, -1, -1],
95
+ Expr\YieldFrom::class => [170, -1, -1],
96
+ Expr\Yield_::class => [175, -1, -1],
97
+ Expr\Print_::class => [180, -1, -1],
98
+ BinaryOp\LogicalAnd::class => [190, 191, 190],
99
+ BinaryOp\LogicalXor::class => [200, 201, 200],
100
+ BinaryOp\LogicalOr::class => [210, 211, 210],
101
+ Expr\Include_::class => [220, -1, -1],
102
+ Expr\ArrowFunction::class => [230, -1, -1],
103
+ Expr\Throw_::class => [240, -1, -1],
92
104
  ];
93
105
 
94
106
  /** @var int Current indentation level. */
95
- protected $indentLevel;
107
+ protected int $indentLevel;
108
+ /** @var string Newline style. Does not include current indentation. */
109
+ protected string $newline;
96
110
  /** @var string Newline including current indentation. */
97
- protected $nl;
98
- /** @var string Token placed at end of doc string to ensure it is followed by a newline. */
99
- protected $docStringEndToken;
111
+ protected string $nl;
112
+ /** @var string|null Token placed at end of doc string to ensure it is followed by a newline.
113
+ * Null if flexible doc strings are used. */
114
+ protected ?string $docStringEndToken;
100
115
  /** @var bool Whether semicolon namespaces can be used (i.e. no global namespace is used) */
101
- protected $canUseSemicolonNamespaces;
102
- /** @var array Pretty printer options */
103
- protected $options;
104
-
105
- /** @var TokenStream Original tokens for use in format-preserving pretty print */
106
- protected $origTokens;
107
- /** @var Internal\Differ Differ for node lists */
108
- protected $nodeListDiffer;
109
- /** @var bool[] Map determining whether a certain character is a label character */
110
- protected $labelCharMap;
116
+ protected bool $canUseSemicolonNamespaces;
117
+ /** @var bool Whether to use short array syntax if the node specifies no preference */
118
+ protected bool $shortArraySyntax;
119
+ /** @var PhpVersion PHP version to target */
120
+ protected PhpVersion $phpVersion;
121
+
122
+ /** @var TokenStream|null Original tokens for use in format-preserving pretty print */
123
+ protected ?TokenStream $origTokens;
124
+ /** @var Internal\Differ<Node> Differ for node lists */
125
+ protected Differ $nodeListDiffer;
126
+ /** @var array<string, bool> Map determining whether a certain character is a label character */
127
+ protected array $labelCharMap;
128
+ /**
129
+ * @var array<string, array<string, int>> Map from token classes and subnode names to FIXUP_* constants.
130
+ * This is used during format-preserving prints to place additional parens/braces if necessary.
131
+ */
132
+ protected array $fixupMap;
111
133
  /**
112
- * @var int[][] Map from token classes and subnode names to FIXUP_* constants. This is used
113
- * during format-preserving prints to place additional parens/braces if necessary.
134
+ * @var array<string, array{left?: int|string, right?: int|string}> Map from "{$node->getType()}->{$subNode}"
135
+ * to ['left' => $l, 'right' => $r], where $l and $r specify the token type that needs to be stripped
136
+ * when removing this node.
114
137
  */
115
- protected $fixupMap;
138
+ protected array $removalMap;
116
139
  /**
117
- * @var int[][] Map from "{$node->getType()}->{$subNode}" to ['left' => $l, 'right' => $r],
118
- * where $l and $r specify the token type that needs to be stripped when removing
119
- * this node.
140
+ * @var array<string, array{int|string|null, bool, string|null, string|null}> Map from
141
+ * "{$node->getType()}->{$subNode}" to [$find, $beforeToken, $extraLeft, $extraRight].
142
+ * $find is an optional token after which the insertion occurs. $extraLeft/Right
143
+ * are optionally added before/after the main insertions.
120
144
  */
121
- protected $removalMap;
145
+ protected array $insertionMap;
122
146
  /**
123
- * @var mixed[] Map from "{$node->getType()}->{$subNode}" to [$find, $beforeToken, $extraLeft, $extraRight].
124
- * $find is an optional token after which the insertion occurs. $extraLeft/Right
125
- * are optionally added before/after the main insertions.
147
+ * @var array<string, string> Map From "{$class}->{$subNode}" to string that should be inserted
148
+ * between elements of this list subnode.
126
149
  */
127
- protected $insertionMap;
150
+ protected array $listInsertionMap;
151
+
128
152
  /**
129
- * @var string[] Map From "{$node->getType()}->{$subNode}" to string that should be inserted
130
- * between elements of this list subnode.
153
+ * @var array<string, array{int|string|null, string, string}>
131
154
  */
132
- protected $listInsertionMap;
133
- protected $emptyListInsertionMap;
134
- /** @var int[] Map from "{$node->getType()}->{$subNode}" to token before which the modifiers
135
- * should be reprinted. */
136
- protected $modifierChangeMap;
155
+ protected array $emptyListInsertionMap;
156
+ /** @var array<string, array{string, int}> Map from "{$class}->{$subNode}" to [$printFn, $token]
157
+ * where $printFn is the function to print the modifiers and $token is the token before which
158
+ * the modifiers should be reprinted. */
159
+ protected array $modifierChangeMap;
137
160
 
138
161
  /**
139
162
  * Creates a pretty printer instance using the given options.
140
163
  *
141
164
  * Supported options:
142
- * * bool $shortArraySyntax = false: Whether to use [] instead of array() as the default array
143
- * syntax, if the node does not specify a format.
165
+ * * PhpVersion $phpVersion: The PHP version to target (default to PHP 7.4). This option
166
+ * controls compatibility of the generated code with older PHP
167
+ * versions in cases where a simple stylistic choice exists (e.g.
168
+ * array() vs []). It is safe to pretty-print an AST for a newer
169
+ * PHP version while specifying an older target (but the result will
170
+ * of course not be compatible with the older version in that case).
171
+ * * string $newline: The newline style to use. Should be "\n" (default) or "\r\n".
172
+ * * bool $shortArraySyntax: Whether to use [] instead of array() as the default array
173
+ * syntax, if the node does not specify a format. Defaults to whether
174
+ * the phpVersion support short array syntax.
144
175
  *
145
- * @param array $options Dictionary of formatting options
176
+ * @param array{
177
+ * phpVersion?: PhpVersion, newline?: string, shortArraySyntax?: bool
178
+ * } $options Dictionary of formatting options
146
179
  */
147
180
  public function __construct(array $options = []) {
148
- $this->docStringEndToken = '_DOC_STRING_END_' . mt_rand();
181
+ $this->phpVersion = $options['phpVersion'] ?? PhpVersion::fromComponents(7, 4);
149
182
 
150
- $defaultOptions = ['shortArraySyntax' => false];
151
- $this->options = $options + $defaultOptions;
183
+ $this->newline = $options['newline'] ?? "\n";
184
+ if ($this->newline !== "\n" && $this->newline != "\r\n") {
185
+ throw new \LogicException('Option "newline" must be one of "\n" or "\r\n"');
186
+ }
187
+
188
+ $this->shortArraySyntax =
189
+ $options['shortArraySyntax'] ?? $this->phpVersion->supportsShortArraySyntax();
190
+ $this->docStringEndToken =
191
+ $this->phpVersion->supportsFlexibleHeredoc() ? null : '_DOC_STRING_END_' . mt_rand();
152
192
  }
153
193
 
154
194
  /**
155
195
  * Reset pretty printing state.
156
196
  */
157
- protected function resetState() {
197
+ protected function resetState(): void {
158
198
  $this->indentLevel = 0;
159
- $this->nl = "\n";
199
+ $this->nl = $this->newline;
160
200
  $this->origTokens = null;
161
201
  }
162
202
 
@@ -165,15 +205,15 @@ abstract class PrettyPrinterAbstract
165
205
  *
166
206
  * @param int $level Level in number of spaces
167
207
  */
168
- protected function setIndentLevel(int $level) {
208
+ protected function setIndentLevel(int $level): void {
169
209
  $this->indentLevel = $level;
170
- $this->nl = "\n" . \str_repeat(' ', $level);
210
+ $this->nl = $this->newline . \str_repeat(' ', $level);
171
211
  }
172
212
 
173
213
  /**
174
214
  * Increase indentation level.
175
215
  */
176
- protected function indent() {
216
+ protected function indent(): void {
177
217
  $this->indentLevel += 4;
178
218
  $this->nl .= ' ';
179
219
  }
@@ -181,10 +221,10 @@ abstract class PrettyPrinterAbstract
181
221
  /**
182
222
  * Decrease indentation level.
183
223
  */
184
- protected function outdent() {
224
+ protected function outdent(): void {
185
225
  assert($this->indentLevel >= 4);
186
226
  $this->indentLevel -= 4;
187
- $this->nl = "\n" . str_repeat(' ', $this->indentLevel);
227
+ $this->nl = $this->newline . str_repeat(' ', $this->indentLevel);
188
228
  }
189
229
 
190
230
  /**
@@ -194,7 +234,7 @@ abstract class PrettyPrinterAbstract
194
234
  *
195
235
  * @return string Pretty printed statements
196
236
  */
197
- public function prettyPrint(array $stmts) : string {
237
+ public function prettyPrint(array $stmts): string {
198
238
  $this->resetState();
199
239
  $this->preprocessNodes($stmts);
200
240
 
@@ -208,7 +248,7 @@ abstract class PrettyPrinterAbstract
208
248
  *
209
249
  * @return string Pretty printed node
210
250
  */
211
- public function prettyPrintExpr(Expr $node) : string {
251
+ public function prettyPrintExpr(Expr $node): string {
212
252
  $this->resetState();
213
253
  return $this->handleMagicTokens($this->p($node));
214
254
  }
@@ -220,15 +260,15 @@ abstract class PrettyPrinterAbstract
220
260
  *
221
261
  * @return string Pretty printed statements
222
262
  */
223
- public function prettyPrintFile(array $stmts) : string {
263
+ public function prettyPrintFile(array $stmts): string {
224
264
  if (!$stmts) {
225
- return "<?php\n\n";
265
+ return "<?php" . $this->newline . $this->newline;
226
266
  }
227
267
 
228
- $p = "<?php\n\n" . $this->prettyPrint($stmts);
268
+ $p = "<?php" . $this->newline . $this->newline . $this->prettyPrint($stmts);
229
269
 
230
270
  if ($stmts[0] instanceof Stmt\InlineHTML) {
231
- $p = preg_replace('/^<\?php\s+\?>\n?/', '', $p);
271
+ $p = preg_replace('/^<\?php\s+\?>\r?\n?/', '', $p);
232
272
  }
233
273
  if ($stmts[count($stmts) - 1] instanceof Stmt\InlineHTML) {
234
274
  $p = preg_replace('/<\?php$/', '', rtrim($p));
@@ -242,7 +282,7 @@ abstract class PrettyPrinterAbstract
242
282
  *
243
283
  * @param Node[] $nodes Array of nodes
244
284
  */
245
- protected function preprocessNodes(array $nodes) {
285
+ protected function preprocessNodes(array $nodes): void {
246
286
  /* We can use semicolon-namespaces unless there is a global namespace declaration */
247
287
  $this->canUseSemicolonNamespaces = true;
248
288
  foreach ($nodes as $node) {
@@ -254,15 +294,17 @@ abstract class PrettyPrinterAbstract
254
294
  }
255
295
 
256
296
  /**
257
- * Handles (and removes) no-indent and doc-string-end tokens.
258
- *
259
- * @param string $str
260
- * @return string
297
+ * Handles (and removes) doc-string-end tokens.
261
298
  */
262
- protected function handleMagicTokens(string $str) : string {
263
- // Replace doc-string-end tokens with nothing or a newline
264
- $str = str_replace($this->docStringEndToken . ";\n", ";\n", $str);
265
- $str = str_replace($this->docStringEndToken, "\n", $str);
299
+ protected function handleMagicTokens(string $str): string {
300
+ if ($this->docStringEndToken !== null) {
301
+ // Replace doc-string-end tokens with nothing or a newline
302
+ $str = str_replace(
303
+ $this->docStringEndToken . ';' . $this->newline,
304
+ ';' . $this->newline,
305
+ $str);
306
+ $str = str_replace($this->docStringEndToken, $this->newline, $str);
307
+ }
266
308
 
267
309
  return $str;
268
310
  }
@@ -270,12 +312,12 @@ abstract class PrettyPrinterAbstract
270
312
  /**
271
313
  * Pretty prints an array of nodes (statements) and indents them optionally.
272
314
  *
273
- * @param Node[] $nodes Array of nodes
274
- * @param bool $indent Whether to indent the printed nodes
315
+ * @param Node[] $nodes Array of nodes
316
+ * @param bool $indent Whether to indent the printed nodes
275
317
  *
276
318
  * @return string Pretty printed statements
277
319
  */
278
- protected function pStmts(array $nodes, bool $indent = true) : string {
320
+ protected function pStmts(array $nodes, bool $indent = true): string {
279
321
  if ($indent) {
280
322
  $this->indent();
281
323
  }
@@ -303,84 +345,96 @@ abstract class PrettyPrinterAbstract
303
345
  /**
304
346
  * Pretty-print an infix operation while taking precedence into account.
305
347
  *
306
- * @param string $class Node class of operator
307
- * @param Node $leftNode Left-hand side node
348
+ * @param string $class Node class of operator
349
+ * @param Node $leftNode Left-hand side node
308
350
  * @param string $operatorString String representation of the operator
309
- * @param Node $rightNode Right-hand side node
351
+ * @param Node $rightNode Right-hand side node
352
+ * @param int $precedence Precedence of parent operator
353
+ * @param int $lhsPrecedence Precedence for unary operator on LHS of binary operator
310
354
  *
311
355
  * @return string Pretty printed infix operation
312
356
  */
313
- protected function pInfixOp(string $class, Node $leftNode, string $operatorString, Node $rightNode) : string {
314
- list($precedence, $associativity) = $this->precedenceMap[$class];
315
-
316
- return $this->pPrec($leftNode, $precedence, $associativity, -1)
317
- . $operatorString
318
- . $this->pPrec($rightNode, $precedence, $associativity, 1);
357
+ protected function pInfixOp(
358
+ string $class, Node $leftNode, string $operatorString, Node $rightNode,
359
+ int $precedence, int $lhsPrecedence
360
+ ): string {
361
+ list($opPrecedence, $newPrecedenceLHS, $newPrecedenceRHS) = $this->precedenceMap[$class];
362
+ $prefix = '';
363
+ $suffix = '';
364
+ if ($opPrecedence >= $precedence) {
365
+ $prefix = '(';
366
+ $suffix = ')';
367
+ $lhsPrecedence = self::MAX_PRECEDENCE;
368
+ }
369
+ return $prefix . $this->p($leftNode, $newPrecedenceLHS, $newPrecedenceLHS)
370
+ . $operatorString . $this->p($rightNode, $newPrecedenceRHS, $lhsPrecedence) . $suffix;
319
371
  }
320
372
 
321
373
  /**
322
374
  * Pretty-print a prefix operation while taking precedence into account.
323
375
  *
324
- * @param string $class Node class of operator
376
+ * @param string $class Node class of operator
325
377
  * @param string $operatorString String representation of the operator
326
- * @param Node $node Node
378
+ * @param Node $node Node
379
+ * @param int $precedence Precedence of parent operator
380
+ * @param int $lhsPrecedence Precedence for unary operator on LHS of binary operator
327
381
  *
328
382
  * @return string Pretty printed prefix operation
329
383
  */
330
- protected function pPrefixOp(string $class, string $operatorString, Node $node) : string {
331
- list($precedence, $associativity) = $this->precedenceMap[$class];
332
- return $operatorString . $this->pPrec($node, $precedence, $associativity, 1);
384
+ protected function pPrefixOp(string $class, string $operatorString, Node $node, int $precedence, int $lhsPrecedence): string {
385
+ $opPrecedence = $this->precedenceMap[$class][0];
386
+ $prefix = '';
387
+ $suffix = '';
388
+ if ($opPrecedence >= $lhsPrecedence) {
389
+ $prefix = '(';
390
+ $suffix = ')';
391
+ $lhsPrecedence = self::MAX_PRECEDENCE;
392
+ }
393
+ $printedArg = $this->p($node, $opPrecedence, $lhsPrecedence);
394
+ if (($operatorString === '+' && $printedArg[0] === '+') ||
395
+ ($operatorString === '-' && $printedArg[0] === '-')
396
+ ) {
397
+ // Avoid printing +(+$a) as ++$a and similar.
398
+ $printedArg = '(' . $printedArg . ')';
399
+ }
400
+ return $prefix . $operatorString . $printedArg . $suffix;
333
401
  }
334
402
 
335
403
  /**
336
404
  * Pretty-print a postfix operation while taking precedence into account.
337
405
  *
338
- * @param string $class Node class of operator
406
+ * @param string $class Node class of operator
339
407
  * @param string $operatorString String representation of the operator
340
- * @param Node $node Node
408
+ * @param Node $node Node
409
+ * @param int $precedence Precedence of parent operator
410
+ * @param int $lhsPrecedence Precedence for unary operator on LHS of binary operator
341
411
  *
342
412
  * @return string Pretty printed postfix operation
343
413
  */
344
- protected function pPostfixOp(string $class, Node $node, string $operatorString) : string {
345
- list($precedence, $associativity) = $this->precedenceMap[$class];
346
- return $this->pPrec($node, $precedence, $associativity, -1) . $operatorString;
347
- }
348
-
349
- /**
350
- * Prints an expression node with the least amount of parentheses necessary to preserve the meaning.
351
- *
352
- * @param Node $node Node to pretty print
353
- * @param int $parentPrecedence Precedence of the parent operator
354
- * @param int $parentAssociativity Associativity of parent operator
355
- * (-1 is left, 0 is nonassoc, 1 is right)
356
- * @param int $childPosition Position of the node relative to the operator
357
- * (-1 is left, 1 is right)
358
- *
359
- * @return string The pretty printed node
360
- */
361
- protected function pPrec(Node $node, int $parentPrecedence, int $parentAssociativity, int $childPosition) : string {
362
- $class = \get_class($node);
363
- if (isset($this->precedenceMap[$class])) {
364
- $childPrecedence = $this->precedenceMap[$class][0];
365
- if ($childPrecedence > $parentPrecedence
366
- || ($parentPrecedence === $childPrecedence && $parentAssociativity !== $childPosition)
367
- ) {
368
- return '(' . $this->p($node) . ')';
369
- }
414
+ protected function pPostfixOp(string $class, Node $node, string $operatorString, int $precedence, int $lhsPrecedence): string {
415
+ $opPrecedence = $this->precedenceMap[$class][0];
416
+ $prefix = '';
417
+ $suffix = '';
418
+ if ($opPrecedence >= $precedence) {
419
+ $prefix = '(';
420
+ $suffix = ')';
421
+ $lhsPrecedence = self::MAX_PRECEDENCE;
370
422
  }
371
-
372
- return $this->p($node);
423
+ if ($opPrecedence < $lhsPrecedence) {
424
+ $lhsPrecedence = $opPrecedence;
425
+ }
426
+ return $prefix . $this->p($node, $opPrecedence, $lhsPrecedence) . $operatorString . $suffix;
373
427
  }
374
428
 
375
429
  /**
376
430
  * Pretty prints an array of nodes and implodes the printed values.
377
431
  *
378
432
  * @param Node[] $nodes Array of Nodes to be printed
379
- * @param string $glue Character to implode with
433
+ * @param string $glue Character to implode with
380
434
  *
381
- * @return string Imploded pretty printed nodes
435
+ * @return string Imploded pretty printed nodes> $pre
382
436
  */
383
- protected function pImplode(array $nodes, string $glue = '') : string {
437
+ protected function pImplode(array $nodes, string $glue = ''): string {
384
438
  $pNodes = [];
385
439
  foreach ($nodes as $node) {
386
440
  if (null === $node) {
@@ -400,7 +454,7 @@ abstract class PrettyPrinterAbstract
400
454
  *
401
455
  * @return string Comma separated pretty printed nodes
402
456
  */
403
- protected function pCommaSeparated(array $nodes) : string {
457
+ protected function pCommaSeparated(array $nodes): string {
404
458
  return $this->pImplode($nodes, ', ');
405
459
  }
406
460
 
@@ -409,12 +463,12 @@ abstract class PrettyPrinterAbstract
409
463
  *
410
464
  * The result includes a leading newline and one level of indentation (same as pStmts).
411
465
  *
412
- * @param Node[] $nodes Array of Nodes to be printed
413
- * @param bool $trailingComma Whether to use a trailing comma
466
+ * @param Node[] $nodes Array of Nodes to be printed
467
+ * @param bool $trailingComma Whether to use a trailing comma
414
468
  *
415
469
  * @return string Comma separated pretty printed nodes in multiline style
416
470
  */
417
- protected function pCommaSeparatedMultiline(array $nodes, bool $trailingComma) : string {
471
+ protected function pCommaSeparatedMultiline(array $nodes, bool $trailingComma): string {
418
472
  $this->indent();
419
473
 
420
474
  $result = '';
@@ -446,7 +500,7 @@ abstract class PrettyPrinterAbstract
446
500
  *
447
501
  * @return string Reformatted text of comments
448
502
  */
449
- protected function pComments(array $comments) : string {
503
+ protected function pComments(array $comments): string {
450
504
  $formattedComments = [];
451
505
 
452
506
  foreach ($comments as $comment) {
@@ -467,13 +521,11 @@ abstract class PrettyPrinterAbstract
467
521
  * * The CloningVisitor must be run on the AST prior to modification.
468
522
  * * The original tokens must be provided, using the getTokens() method on the lexer.
469
523
  *
470
- * @param Node[] $stmts Modified AST with links to original AST
471
- * @param Node[] $origStmts Original AST with token offset information
472
- * @param array $origTokens Tokens of the original code
473
- *
474
- * @return string
524
+ * @param Node[] $stmts Modified AST with links to original AST
525
+ * @param Node[] $origStmts Original AST with token offset information
526
+ * @param Token[] $origTokens Tokens of the original code
475
527
  */
476
- public function printFormatPreserving(array $stmts, array $origStmts, array $origTokens) : string {
528
+ public function printFormatPreserving(array $stmts, array $origStmts, array $origTokens): string {
477
529
  $this->initializeNodeListDiffer();
478
530
  $this->initializeLabelCharMap();
479
531
  $this->initializeFixupMap();
@@ -491,18 +543,18 @@ abstract class PrettyPrinterAbstract
491
543
  $pos = 0;
492
544
  $result = $this->pArray($stmts, $origStmts, $pos, 0, 'File', 'stmts', null);
493
545
  if (null !== $result) {
494
- $result .= $this->origTokens->getTokenCode($pos, count($origTokens), 0);
546
+ $result .= $this->origTokens->getTokenCode($pos, count($origTokens) - 1, 0);
495
547
  } else {
496
548
  // Fallback
497
549
  // TODO Add <?php properly
498
- $result = "<?php\n" . $this->pStmts($stmts, false);
550
+ $result = "<?php" . $this->newline . $this->pStmts($stmts, false);
499
551
  }
500
552
 
501
- return ltrim($this->handleMagicTokens($result));
553
+ return $this->handleMagicTokens($result);
502
554
  }
503
555
 
504
- protected function pFallback(Node $node) {
505
- return $this->{'p' . $node->getType()}($node);
556
+ protected function pFallback(Node $node, int $precedence, int $lhsPrecedence): string {
557
+ return $this->{'p' . $node->getType()}($node, $precedence, $lhsPrecedence);
506
558
  }
507
559
 
508
560
  /**
@@ -511,20 +563,25 @@ abstract class PrettyPrinterAbstract
511
563
  * This method also handles formatting preservation for nodes.
512
564
  *
513
565
  * @param Node $node Node to be pretty printed
566
+ * @param int $precedence Precedence of parent operator
567
+ * @param int $lhsPrecedence Precedence for unary operator on LHS of binary operator
514
568
  * @param bool $parentFormatPreserved Whether parent node has preserved formatting
515
569
  *
516
570
  * @return string Pretty printed node
517
571
  */
518
- protected function p(Node $node, $parentFormatPreserved = false) : string {
572
+ protected function p(
573
+ Node $node, int $precedence = self::MAX_PRECEDENCE, int $lhsPrecedence = self::MAX_PRECEDENCE,
574
+ bool $parentFormatPreserved = false
575
+ ): string {
519
576
  // No orig tokens means this is a normal pretty print without preservation of formatting
520
577
  if (!$this->origTokens) {
521
- return $this->{'p' . $node->getType()}($node);
578
+ return $this->{'p' . $node->getType()}($node, $precedence, $lhsPrecedence);
522
579
  }
523
580
 
524
- /** @var Node $origNode */
581
+ /** @var Node|null $origNode */
525
582
  $origNode = $node->getAttribute('origNode');
526
583
  if (null === $origNode) {
527
- return $this->pFallback($node);
584
+ return $this->pFallback($node, $precedence, $lhsPrecedence);
528
585
  }
529
586
 
530
587
  $class = \get_class($node);
@@ -537,15 +594,17 @@ abstract class PrettyPrinterAbstract
537
594
  $fallbackNode = $node;
538
595
  if ($node instanceof Expr\New_ && $node->class instanceof Stmt\Class_) {
539
596
  // Normalize node structure of anonymous classes
597
+ assert($origNode instanceof Expr\New_);
540
598
  $node = PrintableNewAnonClassNode::fromNewNode($node);
541
599
  $origNode = PrintableNewAnonClassNode::fromNewNode($origNode);
600
+ $class = PrintableNewAnonClassNode::class;
542
601
  }
543
602
 
544
603
  // InlineHTML node does not contain closing and opening PHP tags. If the parent formatting
545
604
  // is not preserved, then we need to use the fallback code to make sure the tags are
546
605
  // printed.
547
606
  if ($node instanceof Stmt\InlineHTML && !$parentFormatPreserved) {
548
- return $this->pFallback($fallbackNode);
607
+ return $this->pFallback($fallbackNode, $precedence, $lhsPrecedence);
549
608
  }
550
609
 
551
610
  $indentAdjustment = $this->indentLevel - $this->origTokens->getIndentationBefore($startPos);
@@ -570,34 +629,27 @@ abstract class PrettyPrinterAbstract
570
629
  if (is_array($subNode) && is_array($origSubNode)) {
571
630
  // Array subnode changed, we might be able to reconstruct it
572
631
  $listResult = $this->pArray(
573
- $subNode, $origSubNode, $pos, $indentAdjustment, $type, $subNodeName,
632
+ $subNode, $origSubNode, $pos, $indentAdjustment, $class, $subNodeName,
574
633
  $fixupInfo[$subNodeName] ?? null
575
634
  );
576
635
  if (null === $listResult) {
577
- return $this->pFallback($fallbackNode);
636
+ return $this->pFallback($fallbackNode, $precedence, $lhsPrecedence);
578
637
  }
579
638
 
580
639
  $result .= $listResult;
581
640
  continue;
582
641
  }
583
642
 
584
- if (is_int($subNode) && is_int($origSubNode)) {
585
- // Check if this is a modifier change
586
- $key = $type . '->' . $subNodeName;
587
- if (!isset($this->modifierChangeMap[$key])) {
588
- return $this->pFallback($fallbackNode);
589
- }
590
-
591
- $findToken = $this->modifierChangeMap[$key];
592
- $result .= $this->pModifiers($subNode);
593
- $pos = $this->origTokens->findRight($pos, $findToken);
594
- continue;
643
+ // Check if this is a modifier change
644
+ $key = $class . '->' . $subNodeName;
645
+ if (!isset($this->modifierChangeMap[$key])) {
646
+ return $this->pFallback($fallbackNode, $precedence, $lhsPrecedence);
595
647
  }
596
648
 
597
- // If a non-node, non-array subnode changed, we don't be able to do a partial
598
- // reconstructions, as we don't have enough offset information. Pretty print the
599
- // whole node instead.
600
- return $this->pFallback($fallbackNode);
649
+ [$printFn, $findToken] = $this->modifierChangeMap[$key];
650
+ $result .= $this->$printFn($subNode);
651
+ $pos = $this->origTokens->findRight($pos, $findToken);
652
+ continue;
601
653
  }
602
654
 
603
655
  $extraLeft = '';
@@ -615,7 +667,7 @@ abstract class PrettyPrinterAbstract
615
667
  // A node has been inserted, check if we have insertion information for it
616
668
  $key = $type . '->' . $subNodeName;
617
669
  if (!isset($this->insertionMap[$key])) {
618
- return $this->pFallback($fallbackNode);
670
+ return $this->pFallback($fallbackNode, $precedence, $lhsPrecedence);
619
671
  }
620
672
 
621
673
  list($findToken, $beforeToken, $extraLeft, $extraRight) = $this->insertionMap[$key];
@@ -637,7 +689,7 @@ abstract class PrettyPrinterAbstract
637
689
  // A node has been removed, check if we have removal information for it
638
690
  $key = $type . '->' . $subNodeName;
639
691
  if (!isset($this->removalMap[$key])) {
640
- return $this->pFallback($fallbackNode);
692
+ return $this->pFallback($fallbackNode, $precedence, $lhsPrecedence);
641
693
  }
642
694
 
643
695
  // Adjust positions to account for additional tokens that must be skipped
@@ -667,7 +719,7 @@ abstract class PrettyPrinterAbstract
667
719
  $fixup = $fixupInfo[$subNodeName];
668
720
  $res = $this->pFixup($fixup, $subNode, $class, $subStartPos, $subEndPos);
669
721
  } else {
670
- $res = $this->p($subNode, true);
722
+ $res = $this->p($subNode, self::MAX_PRECEDENCE, self::MAX_PRECEDENCE, true);
671
723
  }
672
724
 
673
725
  $this->safeAppend($result, $res);
@@ -686,23 +738,23 @@ abstract class PrettyPrinterAbstract
686
738
  /**
687
739
  * Perform a format-preserving pretty print of an array.
688
740
  *
689
- * @param array $nodes New nodes
690
- * @param array $origNodes Original nodes
691
- * @param int $pos Current token position (updated by reference)
692
- * @param int $indentAdjustment Adjustment for indentation
693
- * @param string $parentNodeType Type of the containing node.
694
- * @param string $subNodeName Name of array subnode.
695
- * @param null|int $fixup Fixup information for array item nodes
741
+ * @param Node[] $nodes New nodes
742
+ * @param Node[] $origNodes Original nodes
743
+ * @param int $pos Current token position (updated by reference)
744
+ * @param int $indentAdjustment Adjustment for indentation
745
+ * @param string $parentNodeClass Class of the containing node.
746
+ * @param string $subNodeName Name of array subnode.
747
+ * @param null|int $fixup Fixup information for array item nodes
696
748
  *
697
749
  * @return null|string Result of pretty print or null if cannot preserve formatting
698
750
  */
699
751
  protected function pArray(
700
- array $nodes, array $origNodes, int &$pos, int $indentAdjustment,
701
- string $parentNodeType, string $subNodeName, $fixup
702
- ) {
752
+ array $nodes, array $origNodes, int &$pos, int $indentAdjustment,
753
+ string $parentNodeClass, string $subNodeName, ?int $fixup
754
+ ): ?string {
703
755
  $diff = $this->nodeListDiffer->diffWithReplacements($origNodes, $nodes);
704
756
 
705
- $mapKey = $parentNodeType . '->' . $subNodeName;
757
+ $mapKey = $parentNodeClass . '->' . $subNodeName;
706
758
  $insertStr = $this->listInsertionMap[$mapKey] ?? null;
707
759
  $isStmtList = $subNodeName === 'stmts';
708
760
 
@@ -733,9 +785,9 @@ abstract class PrettyPrinterAbstract
733
785
  $result = '';
734
786
  foreach ($diff as $i => $diffElem) {
735
787
  $diffType = $diffElem->type;
736
- /** @var Node|null $arrItem */
788
+ /** @var Node|string|null $arrItem */
737
789
  $arrItem = $diffElem->new;
738
- /** @var Node|null $origArrItem */
790
+ /** @var Node|string|null $origArrItem */
739
791
  $origArrItem = $diffElem->old;
740
792
 
741
793
  if ($diffType === DiffElem::TYPE_KEEP || $diffType === DiffElem::TYPE_REPLACE) {
@@ -774,8 +826,8 @@ abstract class PrettyPrinterAbstract
774
826
  }
775
827
 
776
828
  if ($skipRemovedNode) {
777
- if ($isStmtList && $this->origTokens->haveBracesInRange($pos, $itemStartPos)) {
778
- // We'd remove the brace of a code block.
829
+ if ($isStmtList && $this->origTokens->haveTagInRange($pos, $itemStartPos)) {
830
+ // We'd remove an opening/closing PHP tag.
779
831
  // TODO: Preserve formatting.
780
832
  $this->setIndentLevel($origIndentLevel);
781
833
  return null;
@@ -795,7 +847,7 @@ abstract class PrettyPrinterAbstract
795
847
  }
796
848
  }
797
849
 
798
- $this->safeAppend($result, $this->p($delayedAddNode, true));
850
+ $this->safeAppend($result, $this->p($delayedAddNode, self::MAX_PRECEDENCE, self::MAX_PRECEDENCE, true));
799
851
 
800
852
  if ($insertNewline) {
801
853
  $result .= $insertStr . $this->nl;
@@ -824,7 +876,18 @@ abstract class PrettyPrinterAbstract
824
876
  return null;
825
877
  }
826
878
 
827
- if ($insertStr === ', ' && $this->isMultiline($origNodes)) {
879
+ if (!$arrItem instanceof Node) {
880
+ // We only support list insertion of nodes.
881
+ return null;
882
+ }
883
+
884
+ // We go multiline if the original code was multiline,
885
+ // or if it's an array item with a comment above it.
886
+ // Match always uses multiline formatting.
887
+ if ($insertStr === ', ' &&
888
+ ($this->isMultiline($origNodes) || $arrItem->getComments() ||
889
+ $parentNodeClass === Expr\Match_::class)
890
+ ) {
828
891
  $insertStr = ',';
829
892
  $insertNewline = true;
830
893
  }
@@ -842,11 +905,11 @@ abstract class PrettyPrinterAbstract
842
905
  $this->setIndentLevel($lastElemIndentLevel);
843
906
 
844
907
  if ($insertNewline) {
908
+ $result .= $insertStr . $this->nl;
845
909
  $comments = $arrItem->getComments();
846
910
  if ($comments) {
847
- $result .= $this->nl . $this->pComments($comments);
911
+ $result .= $this->pComments($comments) . $this->nl;
848
912
  }
849
- $result .= $insertStr . $this->nl;
850
913
  } else {
851
914
  $result .= $insertStr;
852
915
  }
@@ -873,8 +936,8 @@ abstract class PrettyPrinterAbstract
873
936
  $pos, $itemStartPos, $indentAdjustment);
874
937
  $skipRemovedNode = true;
875
938
  } else {
876
- if ($isStmtList && $this->origTokens->haveBracesInRange($pos, $itemStartPos)) {
877
- // We'd remove the brace of a code block.
939
+ if ($isStmtList && $this->origTokens->haveTagInRange($pos, $itemStartPos)) {
940
+ // We'd remove an opening/closing PHP tag.
878
941
  // TODO: Preserve formatting.
879
942
  return null;
880
943
  }
@@ -889,7 +952,7 @@ abstract class PrettyPrinterAbstract
889
952
  if (null !== $fixup && $arrItem->getAttribute('origNode') !== $origArrItem) {
890
953
  $res = $this->pFixup($fixup, $arrItem, null, $itemStartPos, $itemEndPos);
891
954
  } else {
892
- $res = $this->p($arrItem, true);
955
+ $res = $this->p($arrItem, self::MAX_PRECEDENCE, self::MAX_PRECEDENCE, true);
893
956
  }
894
957
  $this->safeAppend($result, $res);
895
958
 
@@ -919,11 +982,14 @@ abstract class PrettyPrinterAbstract
919
982
  foreach ($delayedAdd as $delayedAddNode) {
920
983
  if (!$first) {
921
984
  $result .= $insertStr;
985
+ if ($insertNewline) {
986
+ $result .= $this->nl;
987
+ }
922
988
  }
923
- $result .= $this->p($delayedAddNode, true);
989
+ $result .= $this->p($delayedAddNode, self::MAX_PRECEDENCE, self::MAX_PRECEDENCE, true);
924
990
  $first = false;
925
991
  }
926
- $result .= $extraRight;
992
+ $result .= $extraRight === "\n" ? $this->nl : $extraRight;
927
993
  }
928
994
 
929
995
  return $result;
@@ -936,22 +1002,33 @@ abstract class PrettyPrinterAbstract
936
1002
  * are required to preserve program semantics in a certain context (e.g. to maintain precedence
937
1003
  * or because only certain expressions are allowed in certain places).
938
1004
  *
939
- * @param int $fixup Fixup type
940
- * @param Node $subNode Subnode to print
1005
+ * @param int $fixup Fixup type
1006
+ * @param Node $subNode Subnode to print
941
1007
  * @param string|null $parentClass Class of parent node
942
- * @param int $subStartPos Original start pos of subnode
943
- * @param int $subEndPos Original end pos of subnode
1008
+ * @param int $subStartPos Original start pos of subnode
1009
+ * @param int $subEndPos Original end pos of subnode
944
1010
  *
945
1011
  * @return string Result of fixed-up print of subnode
946
1012
  */
947
- protected function pFixup(int $fixup, Node $subNode, $parentClass, int $subStartPos, int $subEndPos) : string {
1013
+ protected function pFixup(int $fixup, Node $subNode, ?string $parentClass, int $subStartPos, int $subEndPos): string {
948
1014
  switch ($fixup) {
949
1015
  case self::FIXUP_PREC_LEFT:
1016
+ // We use a conservative approximation where lhsPrecedence == precedence.
1017
+ if (!$this->origTokens->haveParens($subStartPos, $subEndPos)) {
1018
+ $precedence = $this->precedenceMap[$parentClass][1];
1019
+ return $this->p($subNode, $precedence, $precedence);
1020
+ }
1021
+ break;
950
1022
  case self::FIXUP_PREC_RIGHT:
951
1023
  if (!$this->origTokens->haveParens($subStartPos, $subEndPos)) {
952
- list($precedence, $associativity) = $this->precedenceMap[$parentClass];
953
- return $this->pPrec($subNode, $precedence, $associativity,
954
- $fixup === self::FIXUP_PREC_LEFT ? -1 : 1);
1024
+ $precedence = $this->precedenceMap[$parentClass][2];
1025
+ return $this->p($subNode, $precedence, $precedence);
1026
+ }
1027
+ break;
1028
+ case self::FIXUP_PREC_UNARY:
1029
+ if (!$this->origTokens->haveParens($subStartPos, $subEndPos)) {
1030
+ $precedence = $this->precedenceMap[$parentClass][0];
1031
+ return $this->p($subNode, $precedence, $precedence);
955
1032
  }
956
1033
  break;
957
1034
  case self::FIXUP_CALL_LHS:
@@ -968,6 +1045,19 @@ abstract class PrettyPrinterAbstract
968
1045
  return '(' . $this->p($subNode) . ')';
969
1046
  }
970
1047
  break;
1048
+ case self::FIXUP_STATIC_DEREF_LHS:
1049
+ if ($this->staticDereferenceLhsRequiresParens($subNode)
1050
+ && !$this->origTokens->haveParens($subStartPos, $subEndPos)
1051
+ ) {
1052
+ return '(' . $this->p($subNode) . ')';
1053
+ }
1054
+ break;
1055
+ case self::FIXUP_NEW:
1056
+ if ($this->newOperandRequiresParens($subNode)
1057
+ && !$this->origTokens->haveParens($subStartPos, $subEndPos)) {
1058
+ return '(' . $this->p($subNode) . ')';
1059
+ }
1060
+ break;
971
1061
  case self::FIXUP_BRACED_NAME:
972
1062
  case self::FIXUP_VAR_BRACED_NAME:
973
1063
  if ($subNode instanceof Expr
@@ -978,7 +1068,7 @@ abstract class PrettyPrinterAbstract
978
1068
  }
979
1069
  break;
980
1070
  case self::FIXUP_ENCAPSED:
981
- if (!$subNode instanceof Scalar\EncapsedStringPart
1071
+ if (!$subNode instanceof Node\InterpolatedStringPart
982
1072
  && !$this->origTokens->haveBraces($subStartPos, $subEndPos)
983
1073
  ) {
984
1074
  return '{' . $this->p($subNode) . '}';
@@ -997,11 +1087,8 @@ abstract class PrettyPrinterAbstract
997
1087
  *
998
1088
  * Example: "echo" and "$x" result in "echo$x", but "echo" and "x" result in "echo x".
999
1089
  * Without safeAppend the result would be "echox", which does not preserve semantics.
1000
- *
1001
- * @param string $str
1002
- * @param string $append
1003
1090
  */
1004
- protected function safeAppend(string &$str, string $append) {
1091
+ protected function safeAppend(string &$str, string $append): void {
1005
1092
  if ($str === "") {
1006
1093
  $str = $append;
1007
1094
  return;
@@ -1026,7 +1113,7 @@ abstract class PrettyPrinterAbstract
1026
1113
  *
1027
1114
  * @return bool Whether parentheses are required
1028
1115
  */
1029
- protected function callLhsRequiresParens(Node $node) : bool {
1116
+ protected function callLhsRequiresParens(Node $node): bool {
1030
1117
  return !($node instanceof Node\Name
1031
1118
  || $node instanceof Expr\Variable
1032
1119
  || $node instanceof Expr\ArrayDimFetch
@@ -1038,13 +1125,26 @@ abstract class PrettyPrinterAbstract
1038
1125
  }
1039
1126
 
1040
1127
  /**
1041
- * Determines whether the LHS of a dereferencing operation must be wrapped in parenthesis.
1128
+ * Determines whether the LHS of an array/object operation must be wrapped in parentheses.
1042
1129
  *
1043
1130
  * @param Node $node LHS of dereferencing operation
1044
1131
  *
1045
1132
  * @return bool Whether parentheses are required
1046
1133
  */
1047
- protected function dereferenceLhsRequiresParens(Node $node) : bool {
1134
+ protected function dereferenceLhsRequiresParens(Node $node): bool {
1135
+ // A constant can occur on the LHS of an array/object deref, but not a static deref.
1136
+ return $this->staticDereferenceLhsRequiresParens($node)
1137
+ && !$node instanceof Expr\ConstFetch;
1138
+ }
1139
+
1140
+ /**
1141
+ * Determines whether the LHS of a static operation must be wrapped in parentheses.
1142
+ *
1143
+ * @param Node $node LHS of dereferencing operation
1144
+ *
1145
+ * @return bool Whether parentheses are required
1146
+ */
1147
+ protected function staticDereferenceLhsRequiresParens(Node $node): bool {
1048
1148
  return !($node instanceof Expr\Variable
1049
1149
  || $node instanceof Node\Name
1050
1150
  || $node instanceof Expr\ArrayDimFetch
@@ -1057,10 +1157,31 @@ abstract class PrettyPrinterAbstract
1057
1157
  || $node instanceof Expr\StaticCall
1058
1158
  || $node instanceof Expr\Array_
1059
1159
  || $node instanceof Scalar\String_
1060
- || $node instanceof Expr\ConstFetch
1061
1160
  || $node instanceof Expr\ClassConstFetch);
1062
1161
  }
1063
1162
 
1163
+ /**
1164
+ * Determines whether an expression used in "new" or "instanceof" requires parentheses.
1165
+ *
1166
+ * @param Node $node New or instanceof operand
1167
+ *
1168
+ * @return bool Whether parentheses are required
1169
+ */
1170
+ protected function newOperandRequiresParens(Node $node): bool {
1171
+ if ($node instanceof Node\Name || $node instanceof Expr\Variable) {
1172
+ return false;
1173
+ }
1174
+ if ($node instanceof Expr\ArrayDimFetch || $node instanceof Expr\PropertyFetch ||
1175
+ $node instanceof Expr\NullsafePropertyFetch
1176
+ ) {
1177
+ return $this->newOperandRequiresParens($node->var);
1178
+ }
1179
+ if ($node instanceof Expr\StaticPropertyFetch) {
1180
+ return $this->newOperandRequiresParens($node->class);
1181
+ }
1182
+ return true;
1183
+ }
1184
+
1064
1185
  /**
1065
1186
  * Print modifiers, including trailing whitespace.
1066
1187
  *
@@ -1068,13 +1189,18 @@ abstract class PrettyPrinterAbstract
1068
1189
  *
1069
1190
  * @return string Printed modifiers
1070
1191
  */
1071
- protected function pModifiers(int $modifiers) {
1072
- return ($modifiers & Stmt\Class_::MODIFIER_PUBLIC ? 'public ' : '')
1073
- . ($modifiers & Stmt\Class_::MODIFIER_PROTECTED ? 'protected ' : '')
1074
- . ($modifiers & Stmt\Class_::MODIFIER_PRIVATE ? 'private ' : '')
1075
- . ($modifiers & Stmt\Class_::MODIFIER_STATIC ? 'static ' : '')
1076
- . ($modifiers & Stmt\Class_::MODIFIER_ABSTRACT ? 'abstract ' : '')
1077
- . ($modifiers & Stmt\Class_::MODIFIER_FINAL ? 'final ' : '');
1192
+ protected function pModifiers(int $modifiers): string {
1193
+ return ($modifiers & Modifiers::FINAL ? 'final ' : '')
1194
+ . ($modifiers & Modifiers::ABSTRACT ? 'abstract ' : '')
1195
+ . ($modifiers & Modifiers::PUBLIC ? 'public ' : '')
1196
+ . ($modifiers & Modifiers::PROTECTED ? 'protected ' : '')
1197
+ . ($modifiers & Modifiers::PRIVATE ? 'private ' : '')
1198
+ . ($modifiers & Modifiers::STATIC ? 'static ' : '')
1199
+ . ($modifiers & Modifiers::READONLY ? 'readonly ' : '');
1200
+ }
1201
+
1202
+ protected function pStatic(bool $static): string {
1203
+ return $static ? 'static ' : '';
1078
1204
  }
1079
1205
 
1080
1206
  /**
@@ -1084,7 +1210,7 @@ abstract class PrettyPrinterAbstract
1084
1210
  *
1085
1211
  * @return bool Whether multiline formatting is used
1086
1212
  */
1087
- protected function isMultiline(array $nodes) : bool {
1213
+ protected function isMultiline(array $nodes): bool {
1088
1214
  if (\count($nodes) < 2) {
1089
1215
  return false;
1090
1216
  }
@@ -1116,14 +1242,19 @@ abstract class PrettyPrinterAbstract
1116
1242
  *
1117
1243
  * The label char map determines whether a certain character may occur in a label.
1118
1244
  */
1119
- protected function initializeLabelCharMap() {
1120
- if ($this->labelCharMap) return;
1245
+ protected function initializeLabelCharMap(): void {
1246
+ if (isset($this->labelCharMap)) {
1247
+ return;
1248
+ }
1121
1249
 
1122
1250
  $this->labelCharMap = [];
1123
1251
  for ($i = 0; $i < 256; $i++) {
1124
- // Since PHP 7.1 The lower range is 0x80. However, we also want to support code for
1125
- // older versions.
1126
- $this->labelCharMap[chr($i)] = $i >= 0x7f || ctype_alnum($i);
1252
+ $chr = chr($i);
1253
+ $this->labelCharMap[$chr] = $i >= 0x80 || ctype_alnum($chr);
1254
+ }
1255
+
1256
+ if ($this->phpVersion->allowsDelInIdentifiers()) {
1257
+ $this->labelCharMap["\x7f"] = true;
1127
1258
  }
1128
1259
  }
1129
1260
 
@@ -1132,8 +1263,10 @@ abstract class PrettyPrinterAbstract
1132
1263
  *
1133
1264
  * The node list differ is used to determine differences between two array subnodes.
1134
1265
  */
1135
- protected function initializeNodeListDiffer() {
1136
- if ($this->nodeListDiffer) return;
1266
+ protected function initializeNodeListDiffer(): void {
1267
+ if (isset($this->nodeListDiffer)) {
1268
+ return;
1269
+ }
1137
1270
 
1138
1271
  $this->nodeListDiffer = new Internal\Differ(function ($a, $b) {
1139
1272
  if ($a instanceof Node && $b instanceof Node) {
@@ -1150,28 +1283,30 @@ abstract class PrettyPrinterAbstract
1150
1283
  * The fixup map is used to determine whether a certain subnode of a certain node may require
1151
1284
  * some kind of "fixup" operation, e.g. the addition of parenthesis or braces.
1152
1285
  */
1153
- protected function initializeFixupMap() {
1154
- if ($this->fixupMap) return;
1286
+ protected function initializeFixupMap(): void {
1287
+ if (isset($this->fixupMap)) {
1288
+ return;
1289
+ }
1155
1290
 
1156
1291
  $this->fixupMap = [
1157
- Expr\PreInc::class => ['var' => self::FIXUP_PREC_RIGHT],
1158
- Expr\PreDec::class => ['var' => self::FIXUP_PREC_RIGHT],
1159
- Expr\PostInc::class => ['var' => self::FIXUP_PREC_LEFT],
1160
- Expr\PostDec::class => ['var' => self::FIXUP_PREC_LEFT],
1161
1292
  Expr\Instanceof_::class => [
1162
- 'expr' => self::FIXUP_PREC_LEFT,
1163
- 'class' => self::FIXUP_PREC_RIGHT, // TODO: FIXUP_NEW_VARIABLE
1293
+ 'expr' => self::FIXUP_PREC_UNARY,
1294
+ 'class' => self::FIXUP_NEW,
1164
1295
  ],
1165
1296
  Expr\Ternary::class => [
1166
1297
  'cond' => self::FIXUP_PREC_LEFT,
1167
1298
  'else' => self::FIXUP_PREC_RIGHT,
1168
1299
  ],
1300
+ Expr\Yield_::class => ['value' => self::FIXUP_PREC_UNARY],
1169
1301
 
1170
1302
  Expr\FuncCall::class => ['name' => self::FIXUP_CALL_LHS],
1171
- Expr\StaticCall::class => ['class' => self::FIXUP_DEREF_LHS],
1303
+ Expr\StaticCall::class => ['class' => self::FIXUP_STATIC_DEREF_LHS],
1172
1304
  Expr\ArrayDimFetch::class => ['var' => self::FIXUP_DEREF_LHS],
1173
- Expr\ClassConstFetch::class => ['var' => self::FIXUP_DEREF_LHS],
1174
- Expr\New_::class => ['class' => self::FIXUP_DEREF_LHS], // TODO: FIXUP_NEW_VARIABLE
1305
+ Expr\ClassConstFetch::class => [
1306
+ 'class' => self::FIXUP_STATIC_DEREF_LHS,
1307
+ 'name' => self::FIXUP_BRACED_NAME,
1308
+ ],
1309
+ Expr\New_::class => ['class' => self::FIXUP_NEW],
1175
1310
  Expr\MethodCall::class => [
1176
1311
  'var' => self::FIXUP_DEREF_LHS,
1177
1312
  'name' => self::FIXUP_BRACED_NAME,
@@ -1181,7 +1316,7 @@ abstract class PrettyPrinterAbstract
1181
1316
  'name' => self::FIXUP_BRACED_NAME,
1182
1317
  ],
1183
1318
  Expr\StaticPropertyFetch::class => [
1184
- 'class' => self::FIXUP_DEREF_LHS,
1319
+ 'class' => self::FIXUP_STATIC_DEREF_LHS,
1185
1320
  'name' => self::FIXUP_VAR_BRACED_NAME,
1186
1321
  ],
1187
1322
  Expr\PropertyFetch::class => [
@@ -1192,7 +1327,7 @@ abstract class PrettyPrinterAbstract
1192
1327
  'var' => self::FIXUP_DEREF_LHS,
1193
1328
  'name' => self::FIXUP_BRACED_NAME,
1194
1329
  ],
1195
- Scalar\Encapsed::class => [
1330
+ Scalar\InterpolatedString::class => [
1196
1331
  'parts' => self::FIXUP_ENCAPSED,
1197
1332
  ],
1198
1333
  ];
@@ -1215,27 +1350,19 @@ abstract class PrettyPrinterAbstract
1215
1350
  ];
1216
1351
  }
1217
1352
 
1218
- $assignOps = [
1219
- Expr\Assign::class, Expr\AssignRef::class, AssignOp\Plus::class, AssignOp\Minus::class,
1220
- AssignOp\Mul::class, AssignOp\Div::class, AssignOp\Concat::class, AssignOp\Mod::class,
1221
- AssignOp\BitwiseAnd::class, AssignOp\BitwiseOr::class, AssignOp\BitwiseXor::class,
1222
- AssignOp\ShiftLeft::class, AssignOp\ShiftRight::class, AssignOp\Pow::class, AssignOp\Coalesce::class
1223
- ];
1224
- foreach ($assignOps as $assignOp) {
1225
- $this->fixupMap[$assignOp] = [
1226
- 'var' => self::FIXUP_PREC_LEFT,
1227
- 'expr' => self::FIXUP_PREC_RIGHT,
1228
- ];
1229
- }
1230
-
1231
1353
  $prefixOps = [
1232
- Expr\BitwiseNot::class, Expr\BooleanNot::class, Expr\UnaryPlus::class, Expr\UnaryMinus::class,
1354
+ Expr\Clone_::class, Expr\BitwiseNot::class, Expr\BooleanNot::class, Expr\UnaryPlus::class, Expr\UnaryMinus::class,
1233
1355
  Cast\Int_::class, Cast\Double::class, Cast\String_::class, Cast\Array_::class,
1234
1356
  Cast\Object_::class, Cast\Bool_::class, Cast\Unset_::class, Expr\ErrorSuppress::class,
1235
1357
  Expr\YieldFrom::class, Expr\Print_::class, Expr\Include_::class,
1358
+ Expr\Assign::class, Expr\AssignRef::class, AssignOp\Plus::class, AssignOp\Minus::class,
1359
+ AssignOp\Mul::class, AssignOp\Div::class, AssignOp\Concat::class, AssignOp\Mod::class,
1360
+ AssignOp\BitwiseAnd::class, AssignOp\BitwiseOr::class, AssignOp\BitwiseXor::class,
1361
+ AssignOp\ShiftLeft::class, AssignOp\ShiftRight::class, AssignOp\Pow::class, AssignOp\Coalesce::class,
1362
+ Expr\ArrowFunction::class, Expr\Throw_::class,
1236
1363
  ];
1237
1364
  foreach ($prefixOps as $prefixOp) {
1238
- $this->fixupMap[$prefixOp] = ['expr' => self::FIXUP_PREC_RIGHT];
1365
+ $this->fixupMap[$prefixOp] = ['expr' => self::FIXUP_PREC_UNARY];
1239
1366
  }
1240
1367
  }
1241
1368
 
@@ -1245,8 +1372,10 @@ abstract class PrettyPrinterAbstract
1245
1372
  * The removal map is used to determine which additional tokens should be removed when a
1246
1373
  * certain node is replaced by null.
1247
1374
  */
1248
- protected function initializeRemovalMap() {
1249
- if ($this->removalMap) return;
1375
+ protected function initializeRemovalMap(): void {
1376
+ if (isset($this->removalMap)) {
1377
+ return;
1378
+ }
1250
1379
 
1251
1380
  $stripBoth = ['left' => \T_WHITESPACE, 'right' => \T_WHITESPACE];
1252
1381
  $stripLeft = ['left' => \T_WHITESPACE];
@@ -1256,7 +1385,7 @@ abstract class PrettyPrinterAbstract
1256
1385
  $stripEquals = ['left' => '='];
1257
1386
  $this->removalMap = [
1258
1387
  'Expr_ArrayDimFetch->dim' => $stripBoth,
1259
- 'Expr_ArrayItem->key' => $stripDoubleArrow,
1388
+ 'ArrayItem->key' => $stripDoubleArrow,
1260
1389
  'Expr_ArrowFunction->returnType' => $stripColon,
1261
1390
  'Expr_Closure->returnType' => $stripColon,
1262
1391
  'Expr_Exit->expr' => $stripBoth,
@@ -1267,6 +1396,7 @@ abstract class PrettyPrinterAbstract
1267
1396
  'Param->default' => $stripEquals,
1268
1397
  'Stmt_Break->num' => $stripBoth,
1269
1398
  'Stmt_Catch->var' => $stripLeft,
1399
+ 'Stmt_ClassConst->type' => $stripRight,
1270
1400
  'Stmt_ClassMethod->returnType' => $stripColon,
1271
1401
  'Stmt_Class->extends' => ['left' => \T_EXTENDS],
1272
1402
  'Stmt_Enum->scalarType' => $stripColon,
@@ -1278,7 +1408,7 @@ abstract class PrettyPrinterAbstract
1278
1408
  'Stmt_If->else' => $stripLeft,
1279
1409
  'Stmt_Namespace->name' => $stripLeft,
1280
1410
  'Stmt_Property->type' => $stripRight,
1281
- 'Stmt_PropertyProperty->default' => $stripEquals,
1411
+ 'PropertyItem->default' => $stripEquals,
1282
1412
  'Stmt_Return->expr' => $stripBoth,
1283
1413
  'Stmt_StaticVar->default' => $stripEquals,
1284
1414
  'Stmt_TraitUseAdaptation_Alias->newName' => $stripLeft,
@@ -1290,16 +1420,18 @@ abstract class PrettyPrinterAbstract
1290
1420
  ];
1291
1421
  }
1292
1422
 
1293
- protected function initializeInsertionMap() {
1294
- if ($this->insertionMap) return;
1423
+ protected function initializeInsertionMap(): void {
1424
+ if (isset($this->insertionMap)) {
1425
+ return;
1426
+ }
1295
1427
 
1296
1428
  // TODO: "yield" where both key and value are inserted doesn't work
1297
1429
  // [$find, $beforeToken, $extraLeft, $extraRight]
1298
1430
  $this->insertionMap = [
1299
1431
  'Expr_ArrayDimFetch->dim' => ['[', false, null, null],
1300
- 'Expr_ArrayItem->key' => [null, false, null, ' => '],
1301
- 'Expr_ArrowFunction->returnType' => [')', false, ' : ', null],
1302
- 'Expr_Closure->returnType' => [')', false, ' : ', null],
1432
+ 'ArrayItem->key' => [null, false, null, ' => '],
1433
+ 'Expr_ArrowFunction->returnType' => [')', false, ': ', null],
1434
+ 'Expr_Closure->returnType' => [')', false, ': ', null],
1303
1435
  'Expr_Ternary->if' => ['?', false, ' ', ' '],
1304
1436
  'Expr_Yield->key' => [\T_YIELD, false, null, ' => '],
1305
1437
  'Expr_Yield->value' => [\T_YIELD, false, ' ', null],
@@ -1307,18 +1439,19 @@ abstract class PrettyPrinterAbstract
1307
1439
  'Param->default' => [null, false, ' = ', null],
1308
1440
  'Stmt_Break->num' => [\T_BREAK, false, ' ', null],
1309
1441
  'Stmt_Catch->var' => [null, false, ' ', null],
1310
- 'Stmt_ClassMethod->returnType' => [')', false, ' : ', null],
1442
+ 'Stmt_ClassMethod->returnType' => [')', false, ': ', null],
1443
+ 'Stmt_ClassConst->type' => [\T_CONST, false, ' ', null],
1311
1444
  'Stmt_Class->extends' => [null, false, ' extends ', null],
1312
1445
  'Stmt_Enum->scalarType' => [null, false, ' : ', null],
1313
1446
  'Stmt_EnumCase->expr' => [null, false, ' = ', null],
1314
- 'Expr_PrintableNewAnonClass->extends' => [null, ' extends ', null],
1447
+ 'Expr_PrintableNewAnonClass->extends' => [null, false, ' extends ', null],
1315
1448
  'Stmt_Continue->num' => [\T_CONTINUE, false, ' ', null],
1316
1449
  'Stmt_Foreach->keyVar' => [\T_AS, false, null, ' => '],
1317
- 'Stmt_Function->returnType' => [')', false, ' : ', null],
1450
+ 'Stmt_Function->returnType' => [')', false, ': ', null],
1318
1451
  'Stmt_If->else' => [null, false, ' ', null],
1319
1452
  'Stmt_Namespace->name' => [\T_NAMESPACE, false, ' ', null],
1320
1453
  'Stmt_Property->type' => [\T_VARIABLE, true, null, ' '],
1321
- 'Stmt_PropertyProperty->default' => [null, false, ' = ', null],
1454
+ 'PropertyItem->default' => [null, false, ' = ', null],
1322
1455
  'Stmt_Return->expr' => [\T_RETURN, false, ' ', null],
1323
1456
  'Stmt_StaticVar->default' => [null, false, ' = ', null],
1324
1457
  //'Stmt_TraitUseAdaptation_Alias->newName' => [T_AS, false, ' ', null], // TODO
@@ -1332,121 +1465,139 @@ abstract class PrettyPrinterAbstract
1332
1465
  ];
1333
1466
  }
1334
1467
 
1335
- protected function initializeListInsertionMap() {
1336
- if ($this->listInsertionMap) return;
1468
+ protected function initializeListInsertionMap(): void {
1469
+ if (isset($this->listInsertionMap)) {
1470
+ return;
1471
+ }
1337
1472
 
1338
1473
  $this->listInsertionMap = [
1339
1474
  // special
1340
1475
  //'Expr_ShellExec->parts' => '', // TODO These need to be treated more carefully
1341
- //'Scalar_Encapsed->parts' => '',
1342
- 'Stmt_Catch->types' => '|',
1343
- 'UnionType->types' => '|',
1344
- 'Stmt_If->elseifs' => ' ',
1345
- 'Stmt_TryCatch->catches' => ' ',
1476
+ //'Scalar_InterpolatedString->parts' => '',
1477
+ Stmt\Catch_::class . '->types' => '|',
1478
+ UnionType::class . '->types' => '|',
1479
+ IntersectionType::class . '->types' => '&',
1480
+ Stmt\If_::class . '->elseifs' => ' ',
1481
+ Stmt\TryCatch::class . '->catches' => ' ',
1346
1482
 
1347
1483
  // comma-separated lists
1348
- 'Expr_Array->items' => ', ',
1349
- 'Expr_ArrowFunction->params' => ', ',
1350
- 'Expr_Closure->params' => ', ',
1351
- 'Expr_Closure->uses' => ', ',
1352
- 'Expr_FuncCall->args' => ', ',
1353
- 'Expr_Isset->vars' => ', ',
1354
- 'Expr_List->items' => ', ',
1355
- 'Expr_MethodCall->args' => ', ',
1356
- 'Expr_NullsafeMethodCall->args' => ', ',
1357
- 'Expr_New->args' => ', ',
1358
- 'Expr_PrintableNewAnonClass->args' => ', ',
1359
- 'Expr_StaticCall->args' => ', ',
1360
- 'Stmt_ClassConst->consts' => ', ',
1361
- 'Stmt_ClassMethod->params' => ', ',
1362
- 'Stmt_Class->implements' => ', ',
1363
- 'Stmt_Enum->implements' => ', ',
1364
- 'Expr_PrintableNewAnonClass->implements' => ', ',
1365
- 'Stmt_Const->consts' => ', ',
1366
- 'Stmt_Declare->declares' => ', ',
1367
- 'Stmt_Echo->exprs' => ', ',
1368
- 'Stmt_For->init' => ', ',
1369
- 'Stmt_For->cond' => ', ',
1370
- 'Stmt_For->loop' => ', ',
1371
- 'Stmt_Function->params' => ', ',
1372
- 'Stmt_Global->vars' => ', ',
1373
- 'Stmt_GroupUse->uses' => ', ',
1374
- 'Stmt_Interface->extends' => ', ',
1375
- 'Stmt_Match->arms' => ', ',
1376
- 'Stmt_Property->props' => ', ',
1377
- 'Stmt_StaticVar->vars' => ', ',
1378
- 'Stmt_TraitUse->traits' => ', ',
1379
- 'Stmt_TraitUseAdaptation_Precedence->insteadof' => ', ',
1380
- 'Stmt_Unset->vars' => ', ',
1381
- 'Stmt_Use->uses' => ', ',
1382
- 'MatchArm->conds' => ', ',
1383
- 'AttributeGroup->attrs' => ', ',
1484
+ Expr\Array_::class . '->items' => ', ',
1485
+ Expr\ArrowFunction::class . '->params' => ', ',
1486
+ Expr\Closure::class . '->params' => ', ',
1487
+ Expr\Closure::class . '->uses' => ', ',
1488
+ Expr\FuncCall::class . '->args' => ', ',
1489
+ Expr\Isset_::class . '->vars' => ', ',
1490
+ Expr\List_::class . '->items' => ', ',
1491
+ Expr\MethodCall::class . '->args' => ', ',
1492
+ Expr\NullsafeMethodCall::class . '->args' => ', ',
1493
+ Expr\New_::class . '->args' => ', ',
1494
+ PrintableNewAnonClassNode::class . '->args' => ', ',
1495
+ Expr\StaticCall::class . '->args' => ', ',
1496
+ Stmt\ClassConst::class . '->consts' => ', ',
1497
+ Stmt\ClassMethod::class . '->params' => ', ',
1498
+ Stmt\Class_::class . '->implements' => ', ',
1499
+ Stmt\Enum_::class . '->implements' => ', ',
1500
+ PrintableNewAnonClassNode::class . '->implements' => ', ',
1501
+ Stmt\Const_::class . '->consts' => ', ',
1502
+ Stmt\Declare_::class . '->declares' => ', ',
1503
+ Stmt\Echo_::class . '->exprs' => ', ',
1504
+ Stmt\For_::class . '->init' => ', ',
1505
+ Stmt\For_::class . '->cond' => ', ',
1506
+ Stmt\For_::class . '->loop' => ', ',
1507
+ Stmt\Function_::class . '->params' => ', ',
1508
+ Stmt\Global_::class . '->vars' => ', ',
1509
+ Stmt\GroupUse::class . '->uses' => ', ',
1510
+ Stmt\Interface_::class . '->extends' => ', ',
1511
+ Expr\Match_::class . '->arms' => ', ',
1512
+ Stmt\Property::class . '->props' => ', ',
1513
+ Stmt\StaticVar::class . '->vars' => ', ',
1514
+ Stmt\TraitUse::class . '->traits' => ', ',
1515
+ Stmt\TraitUseAdaptation\Precedence::class . '->insteadof' => ', ',
1516
+ Stmt\Unset_::class . '->vars' => ', ',
1517
+ Stmt\UseUse::class . '->uses' => ', ',
1518
+ MatchArm::class . '->conds' => ', ',
1519
+ AttributeGroup::class . '->attrs' => ', ',
1384
1520
 
1385
1521
  // statement lists
1386
- 'Expr_Closure->stmts' => "\n",
1387
- 'Stmt_Case->stmts' => "\n",
1388
- 'Stmt_Catch->stmts' => "\n",
1389
- 'Stmt_Class->stmts' => "\n",
1390
- 'Stmt_Enum->stmts' => "\n",
1391
- 'Expr_PrintableNewAnonClass->stmts' => "\n",
1392
- 'Stmt_Interface->stmts' => "\n",
1393
- 'Stmt_Trait->stmts' => "\n",
1394
- 'Stmt_ClassMethod->stmts' => "\n",
1395
- 'Stmt_Declare->stmts' => "\n",
1396
- 'Stmt_Do->stmts' => "\n",
1397
- 'Stmt_ElseIf->stmts' => "\n",
1398
- 'Stmt_Else->stmts' => "\n",
1399
- 'Stmt_Finally->stmts' => "\n",
1400
- 'Stmt_Foreach->stmts' => "\n",
1401
- 'Stmt_For->stmts' => "\n",
1402
- 'Stmt_Function->stmts' => "\n",
1403
- 'Stmt_If->stmts' => "\n",
1404
- 'Stmt_Namespace->stmts' => "\n",
1405
- 'Stmt_Class->attrGroups' => "\n",
1406
- 'Stmt_Enum->attrGroups' => "\n",
1407
- 'Stmt_EnumCase->attrGroups' => "\n",
1408
- 'Stmt_Interface->attrGroups' => "\n",
1409
- 'Stmt_Trait->attrGroups' => "\n",
1410
- 'Stmt_Function->attrGroups' => "\n",
1411
- 'Stmt_ClassMethod->attrGroups' => "\n",
1412
- 'Stmt_ClassConst->attrGroups' => "\n",
1413
- 'Stmt_Property->attrGroups' => "\n",
1414
- 'Expr_PrintableNewAnonClass->attrGroups' => ' ',
1415
- 'Expr_Closure->attrGroups' => ' ',
1416
- 'Expr_ArrowFunction->attrGroups' => ' ',
1417
- 'Param->attrGroups' => ' ',
1418
- 'Stmt_Switch->cases' => "\n",
1419
- 'Stmt_TraitUse->adaptations' => "\n",
1420
- 'Stmt_TryCatch->stmts' => "\n",
1421
- 'Stmt_While->stmts' => "\n",
1522
+ Expr\Closure::class . '->stmts' => "\n",
1523
+ Stmt\Case_::class . '->stmts' => "\n",
1524
+ Stmt\Catch_::class . '->stmts' => "\n",
1525
+ Stmt\Class_::class . '->stmts' => "\n",
1526
+ Stmt\Enum_::class . '->stmts' => "\n",
1527
+ PrintableNewAnonClassNode::class . '->stmts' => "\n",
1528
+ Stmt\Interface_::class . '->stmts' => "\n",
1529
+ Stmt\Trait_::class . '->stmts' => "\n",
1530
+ Stmt\ClassMethod::class . '->stmts' => "\n",
1531
+ Stmt\Declare_::class . '->stmts' => "\n",
1532
+ Stmt\Do_::class . '->stmts' => "\n",
1533
+ Stmt\ElseIf_::class . '->stmts' => "\n",
1534
+ Stmt\Else_::class . '->stmts' => "\n",
1535
+ Stmt\Finally_::class . '->stmts' => "\n",
1536
+ Stmt\Foreach_::class . '->stmts' => "\n",
1537
+ Stmt\For_::class . '->stmts' => "\n",
1538
+ Stmt\Function_::class . '->stmts' => "\n",
1539
+ Stmt\If_::class . '->stmts' => "\n",
1540
+ Stmt\Namespace_::class . '->stmts' => "\n",
1541
+ Stmt\Block::class . '->stmts' => "\n",
1542
+
1543
+ // Attribute groups
1544
+ Stmt\Class_::class . '->attrGroups' => "\n",
1545
+ Stmt\Enum_::class . '->attrGroups' => "\n",
1546
+ Stmt\EnumCase::class . '->attrGroups' => "\n",
1547
+ Stmt\Interface_::class . '->attrGroups' => "\n",
1548
+ Stmt\Trait_::class . '->attrGroups' => "\n",
1549
+ Stmt\Function_::class . '->attrGroups' => "\n",
1550
+ Stmt\ClassMethod::class . '->attrGroups' => "\n",
1551
+ Stmt\ClassConst::class . '->attrGroups' => "\n",
1552
+ Stmt\Property::class . '->attrGroups' => "\n",
1553
+ PrintableNewAnonClassNode::class . '->attrGroups' => ' ',
1554
+ Expr\Closure::class . '->attrGroups' => ' ',
1555
+ Expr\ArrowFunction::class . '->attrGroups' => ' ',
1556
+ Param::class . '->attrGroups' => ' ',
1557
+ Stmt\Switch_::class . '->cases' => "\n",
1558
+ Stmt\TraitUse::class . '->adaptations' => "\n",
1559
+ Stmt\TryCatch::class . '->stmts' => "\n",
1560
+ Stmt\While_::class . '->stmts' => "\n",
1422
1561
 
1423
1562
  // dummy for top-level context
1424
1563
  'File->stmts' => "\n",
1425
1564
  ];
1426
1565
  }
1427
1566
 
1428
- protected function initializeEmptyListInsertionMap() {
1429
- if ($this->emptyListInsertionMap) return;
1567
+ protected function initializeEmptyListInsertionMap(): void {
1568
+ if (isset($this->emptyListInsertionMap)) {
1569
+ return;
1570
+ }
1430
1571
 
1431
1572
  // TODO Insertion into empty statement lists.
1432
1573
 
1433
1574
  // [$find, $extraLeft, $extraRight]
1434
1575
  $this->emptyListInsertionMap = [
1435
- 'Expr_ArrowFunction->params' => ['(', '', ''],
1436
- 'Expr_Closure->uses' => [')', ' use(', ')'],
1437
- 'Expr_Closure->params' => ['(', '', ''],
1438
- 'Expr_FuncCall->args' => ['(', '', ''],
1439
- 'Expr_MethodCall->args' => ['(', '', ''],
1440
- 'Expr_NullsafeMethodCall->args' => ['(', '', ''],
1441
- 'Expr_New->args' => ['(', '', ''],
1442
- 'Expr_PrintableNewAnonClass->args' => ['(', '', ''],
1443
- 'Expr_PrintableNewAnonClass->implements' => [null, ' implements ', ''],
1444
- 'Expr_StaticCall->args' => ['(', '', ''],
1445
- 'Stmt_Class->implements' => [null, ' implements ', ''],
1446
- 'Stmt_Enum->implements' => [null, ' implements ', ''],
1447
- 'Stmt_ClassMethod->params' => ['(', '', ''],
1448
- 'Stmt_Interface->extends' => [null, ' extends ', ''],
1449
- 'Stmt_Function->params' => ['(', '', ''],
1576
+ Expr\ArrowFunction::class . '->params' => ['(', '', ''],
1577
+ Expr\Closure::class . '->uses' => [')', ' use (', ')'],
1578
+ Expr\Closure::class . '->params' => ['(', '', ''],
1579
+ Expr\FuncCall::class . '->args' => ['(', '', ''],
1580
+ Expr\MethodCall::class . '->args' => ['(', '', ''],
1581
+ Expr\NullsafeMethodCall::class . '->args' => ['(', '', ''],
1582
+ Expr\New_::class . '->args' => ['(', '', ''],
1583
+ PrintableNewAnonClassNode::class . '->args' => ['(', '', ''],
1584
+ PrintableNewAnonClassNode::class . '->implements' => [null, ' implements ', ''],
1585
+ Expr\StaticCall::class . '->args' => ['(', '', ''],
1586
+ Stmt\Class_::class . '->implements' => [null, ' implements ', ''],
1587
+ Stmt\Enum_::class . '->implements' => [null, ' implements ', ''],
1588
+ Stmt\ClassMethod::class . '->params' => ['(', '', ''],
1589
+ Stmt\Interface_::class . '->extends' => [null, ' extends ', ''],
1590
+ Stmt\Function_::class . '->params' => ['(', '', ''],
1591
+ Stmt\Interface_::class . '->attrGroups' => [null, '', "\n"],
1592
+ Stmt\Class_::class . '->attrGroups' => [null, '', "\n"],
1593
+ Stmt\ClassConst::class . '->attrGroups' => [null, '', "\n"],
1594
+ Stmt\ClassMethod::class . '->attrGroups' => [null, '', "\n"],
1595
+ Stmt\Function_::class . '->attrGroups' => [null, '', "\n"],
1596
+ Stmt\Property::class . '->attrGroups' => [null, '', "\n"],
1597
+ Stmt\Trait_::class . '->attrGroups' => [null, '', "\n"],
1598
+ Expr\ArrowFunction::class . '->attrGroups' => [null, '', ' '],
1599
+ Expr\Closure::class . '->attrGroups' => [null, '', ' '],
1600
+ PrintableNewAnonClassNode::class . '->attrGroups' => [\T_NEW, ' ', ''],
1450
1601
 
1451
1602
  /* These cannot be empty to start with:
1452
1603
  * Expr_Isset->vars
@@ -1478,22 +1629,27 @@ abstract class PrettyPrinterAbstract
1478
1629
  ];
1479
1630
  }
1480
1631
 
1481
- protected function initializeModifierChangeMap() {
1482
- if ($this->modifierChangeMap) return;
1632
+ protected function initializeModifierChangeMap(): void {
1633
+ if (isset($this->modifierChangeMap)) {
1634
+ return;
1635
+ }
1483
1636
 
1484
1637
  $this->modifierChangeMap = [
1485
- 'Stmt_ClassConst->flags' => \T_CONST,
1486
- 'Stmt_ClassMethod->flags' => \T_FUNCTION,
1487
- 'Stmt_Class->flags' => \T_CLASS,
1488
- 'Stmt_Property->flags' => \T_VARIABLE,
1489
- 'Param->flags' => \T_VARIABLE,
1490
- //'Stmt_TraitUseAdaptation_Alias->newModifier' => 0, // TODO
1638
+ Stmt\ClassConst::class . '->flags' => ['pModifiers', \T_CONST],
1639
+ Stmt\ClassMethod::class . '->flags' => ['pModifiers', \T_FUNCTION],
1640
+ Stmt\Class_::class . '->flags' => ['pModifiers', \T_CLASS],
1641
+ Stmt\Property::class . '->flags' => ['pModifiers', \T_VARIABLE],
1642
+ PrintableNewAnonClassNode::class . '->flags' => ['pModifiers', \T_CLASS],
1643
+ Param::class . '->flags' => ['pModifiers', \T_VARIABLE],
1644
+ Expr\Closure::class . '->static' => ['pStatic', \T_FUNCTION],
1645
+ Expr\ArrowFunction::class . '->static' => ['pStatic', \T_FN],
1646
+ //Stmt\TraitUseAdaptation\Alias::class . '->newModifier' => 0, // TODO
1491
1647
  ];
1492
1648
 
1493
1649
  // List of integer subnodes that are not modifiers:
1494
1650
  // Expr_Include->type
1495
1651
  // Stmt_GroupUse->type
1496
1652
  // Stmt_Use->type
1497
- // Stmt_UseUse->type
1653
+ // UseItem->type
1498
1654
  }
1499
1655
  }