@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.
- package/LICENSE +1 -1
- package/README.md +40 -22
- package/boilerplate/skeleton/extension/.github/workflows/backend.yml +1 -1
- package/boilerplate/skeleton/extension/.github/workflows/frontend.yml +2 -1
- package/boilerplate/skeleton/extension/.github/workflows/phpstan.yml +12 -0
- package/boilerplate/skeleton/extension/composer.json +8 -4
- package/boilerplate/skeleton/extension/gitignore +1 -0
- package/boilerplate/skeleton/extension/js/jest.config.cjs +1 -0
- package/boilerplate/skeleton/extension/js/package.json +6 -3
- package/boilerplate/skeleton/extension/js/src/admin/extend.js +8 -0
- package/boilerplate/skeleton/extension/js/src/admin/extend.ts +8 -0
- package/boilerplate/skeleton/extension/js/src/admin/index.js +2 -0
- package/boilerplate/skeleton/extension/js/src/admin/index.ts +3 -1
- package/boilerplate/skeleton/extension/js/src/common/extend.js +5 -0
- package/boilerplate/skeleton/extension/js/src/common/extend.ts +5 -0
- package/boilerplate/skeleton/extension/js/src/common/index.ts +1 -1
- package/boilerplate/skeleton/extension/js/src/forum/extend.js +8 -0
- package/boilerplate/skeleton/extension/js/src/forum/extend.ts +8 -0
- package/boilerplate/skeleton/extension/js/src/forum/index.js +2 -0
- package/boilerplate/skeleton/extension/js/src/forum/index.ts +3 -1
- package/boilerplate/skeleton/extension/js/tests/unit/.gitkeep +0 -0
- package/boilerplate/skeleton/extension/js/tsconfig.test.json +10 -0
- package/boilerplate/skeleton/extension/locale/en.yml +1 -1
- package/boilerplate/skeleton/extension/phpstan.neon +12 -0
- package/boilerplate/skeleton/extension/tests/phpunit.integration.xml +5 -7
- package/boilerplate/skeleton/extension/tests/phpunit.unit.xml +5 -10
- package/boilerplate/stubs/backend/advanced-api-resource.php +85 -0
- package/boilerplate/stubs/backend/api-resource.php +73 -0
- package/boilerplate/stubs/backend/command.php +2 -2
- package/boilerplate/stubs/backend/controller.php +19 -0
- package/boilerplate/stubs/backend/event-listener.php +1 -1
- package/boilerplate/stubs/backend/filter.php +25 -0
- package/boilerplate/stubs/backend/handler/command.php +6 -20
- package/boilerplate/stubs/backend/handler/handler.php +6 -14
- package/boilerplate/stubs/backend/integration-test.php +10 -7
- package/boilerplate/stubs/backend/job.php +6 -11
- package/boilerplate/stubs/backend/mail-driver.php +36 -0
- package/boilerplate/stubs/backend/middleware.php +19 -0
- package/boilerplate/stubs/backend/model.php +1 -1
- package/boilerplate/stubs/backend/notification-blueprint.php +42 -0
- package/boilerplate/stubs/backend/notification-driver.php +32 -0
- package/boilerplate/stubs/backend/policy.php +1 -1
- package/boilerplate/stubs/backend/post-type.php +35 -0
- package/boilerplate/stubs/backend/repository.php +2 -10
- package/boilerplate/stubs/backend/search/driver.php +13 -0
- package/boilerplate/stubs/backend/search/searcher.php +41 -0
- package/boilerplate/stubs/backend/service-provider.php +1 -1
- package/boilerplate/stubs/backend/validator.php +1 -1
- package/boilerplate/stubs/frontend/component.js +1 -1
- package/boilerplate/stubs/frontend/forum-page.js +68 -0
- package/boilerplate/stubs/frontend/gambit/boolean.js +12 -0
- package/boilerplate/stubs/frontend/gambit/key-value.js +16 -0
- package/boilerplate/stubs/frontend/modal.js +1 -1
- package/boilerplate/stubs/frontend/model.js +1 -1
- package/boilerplate/stubs/frontend/notification.js +22 -0
- package/boilerplate/stubs/frontend/post-type.js +13 -0
- package/boilerplate/stubs/migration.php +1 -1
- package/boilerplate/stubs/views/email/html/information.blade.php +8 -0
- package/boilerplate/stubs/views/email/html/notification.blade.php +8 -0
- package/boilerplate/stubs/views/email/plain/information.blade.php +7 -0
- package/boilerplate/stubs/views/email/plain/notification.blade.php +6 -0
- package/lib/base-command.d.ts +19 -5
- package/lib/base-command.js +73 -28
- package/lib/boilersmith/io.d.ts +9 -7
- package/lib/boilersmith/io.js +28 -15
- package/lib/boilersmith/paths.d.ts +1 -1
- package/lib/boilersmith/scaffolding/audit-step-factory.js +1 -1
- package/lib/boilersmith/scaffolding/module.d.ts +4 -4
- package/lib/boilersmith/scaffolding/module.js +6 -6
- package/lib/boilersmith/scaffolding/scaffolder.d.ts +1 -1
- package/lib/boilersmith/scaffolding/scaffolder.js +1 -1
- package/lib/boilersmith/scaffolding/template-param.d.ts +1 -1
- package/lib/boilersmith/step-manager.d.ts +15 -10
- package/lib/boilersmith/step-manager.js +35 -9
- package/lib/boilersmith/steps/stub-base.js +1 -1
- package/lib/boilersmith/utils/json-leaf-paths.d.ts +2 -2
- package/lib/commands/audit/infra.d.ts +1 -4
- package/lib/commands/audit/infra.js +1 -1
- package/lib/commands/flarum/change.js +2 -2
- package/lib/commands/flarum/info.js +1 -1
- package/lib/commands/infra.d.ts +1 -9
- package/lib/commands/infra.js +2 -2
- package/lib/commands/init.d.ts +1 -4
- package/lib/commands/init.js +3 -3
- package/lib/commands/make/backend/{api-serializer.d.ts → api-resource.d.ts} +2 -5
- package/lib/commands/make/backend/api-resource.js +26 -0
- package/lib/commands/make/backend/command.d.ts +1 -4
- package/lib/commands/make/backend/command.js +2 -2
- package/lib/commands/make/backend/{api-controller.d.ts → controller.d.ts} +2 -5
- package/lib/commands/make/backend/controller.js +31 -0
- package/lib/commands/make/backend/event-listener.d.ts +1 -4
- package/lib/commands/make/backend/event-listener.js +1 -1
- package/lib/commands/make/backend/{api-serializer-attributes.d.ts → filter.d.ts} +3 -6
- package/lib/commands/make/backend/filter.js +26 -0
- package/lib/commands/make/backend/handler.d.ts +2 -5
- package/lib/commands/make/backend/handler.js +6 -6
- package/lib/commands/make/backend/integration-test.d.ts +1 -4
- package/lib/commands/make/backend/integration-test.js +2 -2
- package/lib/commands/make/backend/job.d.ts +1 -4
- package/lib/commands/make/backend/job.js +2 -2
- package/lib/commands/make/backend/mail-driver.d.ts +12 -0
- package/lib/commands/make/backend/mail-driver.js +29 -0
- package/lib/commands/make/backend/middleware.d.ts +11 -0
- package/lib/commands/make/backend/middleware.js +26 -0
- package/lib/commands/make/backend/migration.d.ts +1 -4
- package/lib/commands/make/backend/migration.js +9 -2
- package/lib/commands/make/backend/model.d.ts +6 -7
- package/lib/commands/make/backend/model.js +68 -447
- package/lib/commands/make/backend/notification-blueprint.d.ts +12 -0
- package/lib/commands/make/backend/notification-blueprint.js +29 -0
- package/lib/commands/make/backend/notification-driver.d.ts +12 -0
- package/lib/commands/make/backend/notification-driver.js +29 -0
- package/lib/commands/make/backend/policy.d.ts +1 -4
- package/lib/commands/make/backend/policy.js +1 -1
- package/lib/commands/make/backend/post-type.d.ts +12 -0
- package/lib/commands/make/backend/post-type.js +29 -0
- package/lib/commands/make/backend/repository.d.ts +1 -4
- package/lib/commands/make/backend/repository.js +1 -1
- package/lib/commands/make/backend/route.d.ts +1 -4
- package/lib/commands/make/backend/route.js +1 -1
- package/lib/commands/make/backend/search-driver.d.ts +11 -0
- package/lib/commands/make/backend/search-driver.js +51 -0
- package/lib/commands/make/backend/service-provider.d.ts +1 -4
- package/lib/commands/make/backend/service-provider.js +2 -2
- package/lib/commands/make/backend/validator.d.ts +1 -4
- package/lib/commands/make/backend/validator.js +2 -2
- package/lib/commands/make/frontend/component.d.ts +4 -5
- package/lib/commands/make/frontend/component.js +7 -2
- package/lib/commands/make/frontend/forum-page.d.ts +11 -0
- package/lib/commands/make/frontend/forum-page.js +92 -0
- package/lib/commands/make/frontend/gambit.d.ts +11 -0
- package/lib/commands/make/frontend/gambit.js +30 -0
- package/lib/commands/make/frontend/modal.d.ts +1 -4
- package/lib/commands/make/frontend/modal.js +3 -2
- package/lib/commands/make/frontend/model.d.ts +6 -7
- package/lib/commands/make/frontend/model.js +26 -24
- package/lib/commands/make/frontend/notification.d.ts +12 -0
- package/lib/commands/make/frontend/notification.js +62 -0
- package/lib/commands/make/frontend/post-type.d.ts +12 -0
- package/lib/commands/make/frontend/post-type.js +59 -0
- package/lib/commands/make/locale.d.ts +11 -0
- package/lib/commands/make/locale.js +27 -0
- package/lib/commands/make/model.d.ts +12 -0
- package/lib/commands/make/model.js +29 -0
- package/lib/commands/make/notification.d.ts +11 -0
- package/lib/commands/make/notification.js +33 -0
- package/lib/commands/make/post-type.d.ts +11 -0
- package/lib/commands/make/post-type.js +31 -0
- package/lib/commands/monorepo/create.d.ts +1 -4
- package/lib/commands/monorepo/create.js +1 -1
- package/lib/commands/monorepo/split.d.ts +1 -4
- package/lib/commands/monorepo/split.js +1 -1
- package/lib/commands/update/js-imports.d.ts +1 -4
- package/lib/commands/update/js-imports.js +1 -1
- package/lib/commands/upgrade/2.0.d.ts +17 -0
- package/lib/commands/upgrade/2.0.js +113 -0
- package/lib/help.js +1 -1
- package/lib/providers/php-provider.d.ts +7 -1
- package/lib/providers/php-provider.js +16 -3
- package/lib/steps/extenders/{api-serializer.d.ts → api-resource.d.ts} +1 -1
- package/lib/steps/extenders/api-resource.js +38 -0
- package/lib/steps/extenders/base.d.ts +1 -1
- package/lib/steps/extenders/base.js +13 -1
- package/lib/steps/extenders/console-command.js +1 -1
- package/lib/steps/extenders/event.js +1 -1
- package/lib/steps/extenders/mail-driver.d.ts +5 -0
- package/lib/steps/extenders/mail-driver.js +58 -0
- package/lib/steps/extenders/middleware.d.ts +5 -0
- package/lib/steps/extenders/middleware.js +57 -0
- package/lib/steps/extenders/notification-driver.d.ts +5 -0
- package/lib/steps/extenders/notification-driver.js +58 -0
- package/lib/steps/extenders/notification-type.d.ts +5 -0
- package/lib/steps/extenders/notification-type.js +55 -0
- package/lib/steps/extenders/policy.js +1 -1
- package/lib/steps/extenders/post-type.d.ts +5 -0
- package/lib/steps/extenders/post-type.js +42 -0
- package/lib/steps/extenders/route.js +11 -2
- package/lib/steps/extenders/search-driver.d.ts +5 -0
- package/lib/steps/extenders/search-driver.js +38 -0
- package/lib/steps/extenders/search-filter.d.ts +5 -0
- package/lib/steps/extenders/search-filter.js +67 -0
- package/lib/steps/extenders/service-provider.js +1 -1
- package/lib/steps/gen-ext-scaffolder.d.ts +3 -3
- package/lib/steps/gen-ext-scaffolder.js +79 -7
- package/lib/steps/js/base.d.ts +14 -5
- package/lib/steps/js/base.js +101 -25
- package/lib/steps/js/model.d.ts +4 -7
- package/lib/steps/js/model.js +45 -19
- package/lib/steps/js/notification.d.ts +7 -0
- package/lib/steps/js/notification.js +58 -0
- package/lib/steps/js/post-type.d.ts +8 -0
- package/lib/steps/js/post-type.js +60 -0
- package/lib/steps/js/routes.d.ts +7 -0
- package/lib/steps/js/routes.js +63 -0
- package/lib/steps/js/search-driver-locale.d.ts +8 -0
- package/lib/steps/js/search-driver-locale.js +36 -0
- package/lib/steps/js/search-gambit.d.ts +7 -0
- package/lib/steps/js/search-gambit.js +51 -0
- package/lib/steps/locale/base.d.ts +32 -0
- package/lib/steps/locale/base.js +97 -0
- package/lib/steps/misc/git.js +1 -1
- package/lib/steps/monorepo/create.d.ts +2 -0
- package/lib/steps/monorepo/create.js +5 -4
- package/lib/steps/monorepo/split.js +1 -1
- package/lib/steps/stubs/backend/advanced-api-resource.d.ts +13 -0
- package/lib/steps/stubs/backend/advanced-api-resource.js +81 -0
- package/lib/steps/stubs/backend/{api-serializer.d.ts → api-resource.d.ts} +1 -1
- package/lib/steps/stubs/backend/{api-serializer.js → api-resource.js} +9 -9
- package/lib/steps/stubs/backend/command.d.ts +2 -16
- package/lib/steps/stubs/backend/command.js +14 -1
- package/lib/steps/stubs/backend/{api-controller.d.ts → controller.d.ts} +3 -13
- package/lib/steps/stubs/backend/controller.js +40 -0
- package/lib/steps/stubs/backend/event-listener.js +1 -1
- package/lib/steps/stubs/backend/filter.d.ts +8 -0
- package/lib/steps/stubs/backend/filter.js +44 -0
- package/lib/steps/stubs/backend/handler-command.d.ts +2 -27
- package/lib/steps/stubs/backend/handler-command.js +2 -1
- package/lib/steps/stubs/backend/handler.js +1 -1
- package/lib/steps/stubs/backend/integration-test.js +0 -5
- package/lib/steps/stubs/backend/mail-driver.d.ts +7 -0
- package/lib/steps/stubs/backend/mail-driver.js +30 -0
- package/lib/steps/stubs/backend/middleware.d.ts +22 -0
- package/lib/steps/stubs/backend/middleware.js +31 -0
- package/lib/steps/stubs/backend/model.d.ts +2 -24
- package/lib/steps/stubs/backend/model.js +2 -5
- package/lib/steps/stubs/backend/notification-blueprint.d.ts +7 -0
- package/lib/steps/stubs/backend/notification-blueprint.js +44 -0
- package/lib/steps/stubs/backend/notification-driver.d.ts +7 -0
- package/lib/steps/stubs/backend/notification-driver.js +30 -0
- package/lib/steps/stubs/backend/policy.js +1 -1
- package/lib/steps/stubs/backend/post-type.d.ts +7 -0
- package/lib/steps/stubs/backend/post-type.js +44 -0
- package/lib/steps/stubs/backend/repository.js +1 -1
- package/lib/steps/stubs/backend/search-driver-searcher.d.ts +24 -0
- package/lib/steps/stubs/backend/search-driver-searcher.js +32 -0
- package/lib/steps/stubs/backend/search-driver.d.ts +8 -0
- package/lib/steps/stubs/backend/search-driver.js +49 -0
- package/lib/steps/stubs/flarum-base.js +1 -1
- package/lib/steps/stubs/frontend/forum-page.d.ts +25 -0
- package/lib/steps/stubs/frontend/forum-page.js +37 -0
- package/lib/steps/stubs/frontend/gambit.d.ts +7 -0
- package/lib/steps/stubs/frontend/gambit.js +50 -0
- package/lib/steps/stubs/frontend/model.d.ts +12 -0
- package/lib/steps/stubs/frontend/model.js +5 -0
- package/lib/steps/stubs/frontend/notification.d.ts +11 -0
- package/lib/steps/stubs/frontend/notification.js +48 -0
- package/lib/steps/stubs/frontend/post-type.d.ts +11 -0
- package/lib/steps/stubs/frontend/post-type.js +48 -0
- package/lib/steps/stubs/js-base.js +5 -1
- package/lib/steps/stubs/php-base.js +3 -1
- package/lib/steps/update/js-imports.js +1 -1
- package/lib/steps/upgrade/twopointoh/backend/email-views.d.ts +18 -0
- package/lib/steps/upgrade/twopointoh/backend/email-views.js +81 -0
- package/lib/steps/upgrade/twopointoh/backend/filesystem.d.ts +8 -0
- package/lib/steps/upgrade/twopointoh/backend/filesystem.js +40 -0
- package/lib/steps/upgrade/twopointoh/backend/intervention-image.d.ts +8 -0
- package/lib/steps/upgrade/twopointoh/backend/intervention-image.js +44 -0
- package/lib/steps/upgrade/twopointoh/backend/json-api.d.ts +12 -0
- package/lib/steps/upgrade/twopointoh/backend/json-api.js +111 -0
- package/lib/steps/upgrade/twopointoh/backend/mailer.d.ts +8 -0
- package/lib/steps/upgrade/twopointoh/backend/mailer.js +37 -0
- package/lib/steps/upgrade/twopointoh/backend/misc.d.ts +8 -0
- package/lib/steps/upgrade/twopointoh/backend/misc.js +42 -0
- package/lib/steps/upgrade/twopointoh/backend/phpunit.d.ts +8 -0
- package/lib/steps/upgrade/twopointoh/backend/phpunit.js +52 -0
- package/lib/steps/upgrade/twopointoh/backend/search.d.ts +28 -0
- package/lib/steps/upgrade/twopointoh/backend/search.js +200 -0
- package/lib/steps/upgrade/twopointoh/base.d.ts +58 -0
- package/lib/steps/upgrade/twopointoh/base.js +284 -0
- package/lib/steps/upgrade/twopointoh/dependencies.d.ts +10 -0
- package/lib/steps/upgrade/twopointoh/dependencies.js +108 -0
- package/lib/steps/upgrade/twopointoh/frontend/code-splitting/usage-of-lazy-modules.d.ts +26 -0
- package/lib/steps/upgrade/twopointoh/frontend/code-splitting/usage-of-lazy-modules.js +418 -0
- package/lib/steps/upgrade/twopointoh/frontend/export-registry/compat.d.ts +12 -0
- package/lib/steps/upgrade/twopointoh/frontend/export-registry/compat.js +75 -0
- package/lib/steps/upgrade/twopointoh/frontend/export-registry/import-ext.d.ts +13 -0
- package/lib/steps/upgrade/twopointoh/frontend/export-registry/import-ext.js +126 -0
- package/lib/steps/upgrade/twopointoh/frontend/format.d.ts +8 -0
- package/lib/steps/upgrade/twopointoh/frontend/format.js +32 -0
- package/lib/steps/upgrade/twopointoh/frontend/misc.d.ts +17 -0
- package/lib/steps/upgrade/twopointoh/frontend/misc.js +433 -0
- package/lib/steps/upgrade/twopointoh/infra.d.ts +10 -0
- package/lib/steps/upgrade/twopointoh/infra.js +51 -0
- package/lib/steps/upgrade/twopointoh/less.d.ts +12 -0
- package/lib/steps/upgrade/twopointoh/less.js +217 -0
- package/lib/utils/add-extenders.d.ts +2 -0
- package/lib/utils/add-extenders.js +115 -0
- package/lib/utils/ast.d.ts +22 -0
- package/lib/utils/ast.js +235 -0
- package/lib/utils/composer.d.ts +1 -1
- package/lib/utils/model-name.d.ts +1 -0
- package/lib/utils/model-name.js +7 -3
- package/lib/utils/monorepo.d.ts +2 -2
- package/lib/utils/validation.d.ts +4 -1
- package/lib/utils/validation.js +9 -0
- package/oclif.manifest.json +1 -1
- package/package.json +20 -13
- package/php-subsystem/composer.json +3 -1
- package/php-subsystem/composer.lock +13 -11
- package/php-subsystem/index.php +41 -6
- package/php-subsystem/src/CustomPrettyPrinter.php +1 -1
- package/php-subsystem/src/ExtenderUtil.php +7 -13
- package/php-subsystem/src/NodeUtil.php +72 -0
- package/php-subsystem/src/NodeVisitors/AddExtender.php +28 -12
- package/php-subsystem/src/NodeVisitors/AddUses.php +24 -0
- package/php-subsystem/src/NodeVisitors/ChangeSignatures.php +200 -0
- package/php-subsystem/src/NodeVisitors/ReplaceUses.php +175 -0
- package/php-subsystem/src/Upgrade/Replacement.php +51 -0
- package/php-subsystem/src/Upgrade/ReplacementResult.php +17 -0
- package/php-subsystem/src/Upgrade/TwoPointOh/EmailViews.php +94 -0
- package/php-subsystem/src/Upgrade/TwoPointOh/Filesystem.php +88 -0
- package/php-subsystem/src/Upgrade/TwoPointOh/InterventionImage.php +86 -0
- package/php-subsystem/src/Upgrade/TwoPointOh/JsonApi.php +186 -0
- package/php-subsystem/src/Upgrade/TwoPointOh/Misc.php +584 -0
- package/php-subsystem/src/Upgrade/TwoPointOh/PhpUnit.php +241 -0
- package/php-subsystem/src/Upgrade/TwoPointOh/Search.php +589 -0
- package/php-subsystem/vendor/autoload.php +18 -0
- package/php-subsystem/vendor/bin/php-parse +119 -0
- package/php-subsystem/vendor/composer/ClassLoader.php +166 -32
- package/php-subsystem/vendor/composer/InstalledVersions.php +350 -209
- package/php-subsystem/vendor/composer/autoload_classmap.php +1 -1
- package/php-subsystem/vendor/composer/autoload_namespaces.php +1 -1
- package/php-subsystem/vendor/composer/autoload_psr4.php +1 -1
- package/php-subsystem/vendor/composer/autoload_real.php +3 -22
- package/php-subsystem/vendor/composer/installed.json +12 -10
- package/php-subsystem/vendor/composer/installed.php +29 -30
- package/php-subsystem/vendor/composer/platform_check.php +2 -2
- package/php-subsystem/vendor/nikic/php-parser/README.md +74 -62
- package/php-subsystem/vendor/nikic/php-parser/bin/php-parse +12 -11
- package/php-subsystem/vendor/nikic/php-parser/composer.json +6 -4
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php +58 -11
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/Class_.php +54 -25
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/Declaration.php +11 -4
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/EnumCase.php +87 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/Enum_.php +116 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php +8 -9
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/Function_.php +22 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/Interface_.php +26 -7
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php +31 -13
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/Namespace_.php +5 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php +69 -26
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php +47 -18
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUse.php +6 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php +25 -28
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/Trait_.php +31 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder/Use_.php +8 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Builder.php +2 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/BuilderFactory.php +85 -70
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/BuilderHelpers.php +119 -71
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Comment/Doc.php +1 -2
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Comment.php +35 -67
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/ConstExprEvaluationException.php +3 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/ConstExprEvaluator.php +17 -9
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Error.php +24 -33
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/ErrorHandler/Collecting.php +6 -9
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/ErrorHandler/Throwing.php +2 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/ErrorHandler.php +2 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Internal/DiffElem.php +11 -7
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Internal/Differ.php +36 -22
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Internal/PrintableNewAnonClassNode.php +24 -14
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php +237 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php +63 -69
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/JsonDecoder.php +15 -10
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php +74 -92
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/AttributeEmulator.php +11 -18
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/EnumTokenEmulator.php +10 -15
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ExplicitOctalEmulator.php +45 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/KeywordEmulator.php +19 -25
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/MatchTokenEmulator.php +6 -10
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NullsafeTokenEmulator.php +22 -29
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyFunctionTokenEmulator.php +31 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyTokenEmulator.php +31 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReverseEmulator.php +6 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/TokenEmulator.php +10 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer.php +70 -491
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Modifiers.php +69 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NameContext.php +23 -24
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Arg.php +13 -14
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/ArrayItem.php +43 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Attribute.php +9 -10
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/AttributeGroup.php +5 -7
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/ClosureUse.php +36 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/ComplexType.php +13 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Const_.php +12 -13
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/DeclareItem.php +37 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayDimFetch.php +10 -11
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayItem.php +1 -39
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Array_.php +11 -11
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrowFunction.php +35 -30
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Assign.php +9 -10
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseAnd.php +2 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseOr.php +2 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseXor.php +2 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Coalesce.php +2 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Concat.php +2 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Div.php +2 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Minus.php +2 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Mod.php +2 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Mul.php +2 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Plus.php +2 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Pow.php +2 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/ShiftLeft.php +2 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/ShiftRight.php +2 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignRef.php +9 -10
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseAnd.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseOr.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseXor.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BooleanAnd.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BooleanOr.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Coalesce.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Concat.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Div.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Equal.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Greater.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/GreaterOrEqual.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Identical.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalAnd.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalOr.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalXor.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Minus.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Mod.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Mul.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/NotEqual.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/NotIdentical.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Plus.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Pow.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftLeft.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftRight.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Smaller.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/SmallerOrEqual.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Spaceship.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp.php +8 -11
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BitwiseNot.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BooleanNot.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/CallLike.php +35 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Array_.php +2 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Bool_.php +2 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Double.php +5 -6
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Int_.php +2 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Object_.php +2 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/String_.php +2 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Unset_.php +2 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast.php +5 -6
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ClassConstFetch.php +12 -12
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Clone_.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Closure.php +34 -27
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ClosureUse.php +1 -32
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ConstFetch.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Empty_.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Error.php +5 -6
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ErrorSuppress.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Eval_.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Exit_.php +10 -11
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/FuncCall.php +15 -12
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Include_.php +13 -14
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Instanceof_.php +11 -11
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Isset_.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/List_.php +12 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Match_.php +8 -7
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/MethodCall.php +18 -13
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/New_.php +17 -12
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafeMethodCall.php +18 -13
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafePropertyFetch.php +10 -10
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PostDec.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PostInc.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PreDec.php +6 -7
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PreInc.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Print_.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PropertyFetch.php +10 -10
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ShellExec.php +9 -9
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/StaticCall.php +19 -14
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/StaticPropertyFetch.php +11 -11
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Ternary.php +12 -13
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Throw_.php +6 -7
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryMinus.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryPlus.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Variable.php +6 -7
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/YieldFrom.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Yield_.php +10 -11
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Expr.php +1 -2
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/FunctionLike.php +6 -9
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Identifier.php +13 -13
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/InterpolatedStringPart.php +32 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/IntersectionType.php +27 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/MatchArm.php +8 -9
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Name/FullyQualified.php +8 -9
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Name/Relative.php +8 -9
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Name.php +80 -53
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/NullableType.php +10 -11
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Param.php +47 -23
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/PropertyItem.php +37 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/DNumber.php +1 -68
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/Encapsed.php +1 -29
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/EncapsedStringPart.php +1 -28
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/Float_.php +78 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/Int_.php +82 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/InterpolatedString.php +34 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php +1 -71
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Class_.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Dir.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/File.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Function_.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Line.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Method.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Namespace_.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Trait_.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/String_.php +44 -24
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar.php +1 -2
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/StaticVar.php +39 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Block.php +29 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Break_.php +8 -9
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Case_.php +10 -11
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Catch_.php +11 -12
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassConst.php +33 -27
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassLike.php +15 -15
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassMethod.php +66 -71
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Class_.php +48 -61
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Const_.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Continue_.php +8 -9
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/DeclareDeclare.php +1 -32
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Declare_.php +12 -12
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Do_.php +9 -10
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Echo_.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ElseIf_.php +9 -10
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Else_.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/EnumCase.php +11 -12
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Enum_.php +17 -13
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Expression.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Finally_.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/For_.php +19 -15
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Foreach_.php +20 -17
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Function_.php +31 -27
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Global_.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Goto_.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/GroupUse.php +16 -14
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/HaltCompiler.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/If_.php +18 -15
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/InlineHTML.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Interface_.php +13 -10
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Label.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Namespace_.php +11 -12
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Nop.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Property.php +35 -36
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/PropertyProperty.php +1 -32
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Return_.php +8 -9
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/StaticVar.php +1 -35
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Static_.php +8 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Switch_.php +9 -10
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUse.php +8 -9
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php +12 -13
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php +9 -10
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation.php +3 -4
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Trait_.php +10 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TryCatch.php +11 -12
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Unset_.php +7 -8
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/UseUse.php +1 -50
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Use_.php +16 -16
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/While_.php +9 -10
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt.php +1 -2
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/UnionType.php +8 -11
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/UseItem.php +55 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/VarLikeIdentifier.php +2 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/VariadicPlaceholder.php +27 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node.php +24 -29
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeAbstract.php +20 -20
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeDumper.php +169 -82
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeFinder.php +28 -19
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php +71 -84
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeTraverserInterface.php +4 -7
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/CloningVisitor.php +1 -2
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/CommentAnnotatingVisitor.php +82 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/FindingVisitor.php +4 -5
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/FirstFindingVisitor.php +6 -7
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/NameResolver.php +40 -24
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/NodeConnectingVisitor.php +2 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/ParentConnectingVisitor.php +8 -11
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor.php +59 -7
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/NodeVisitorAbstract.php +1 -2
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Parser/Php7.php +2011 -2058
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Parser/Php8.php +2717 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Parser.php +9 -3
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php +466 -248
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/ParserFactory.php +31 -33
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php +164 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php +419 -338
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter.php +51 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php +587 -431
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Token.php +18 -0
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/compatibility_tokens.php +63 -0
- package/boilerplate/stubs/backend/api-controller/create.php +0 -53
- package/boilerplate/stubs/backend/api-controller/delete.php +0 -52
- package/boilerplate/stubs/backend/api-controller/list.php +0 -61
- package/boilerplate/stubs/backend/api-controller/normal.php +0 -29
- package/boilerplate/stubs/backend/api-controller/show.php +0 -48
- package/boilerplate/stubs/backend/api-controller/update.php +0 -54
- package/boilerplate/stubs/backend/api-serializer.php +0 -36
- package/lib/commands/make/backend/api-controller.js +0 -26
- package/lib/commands/make/backend/api-serializer-attributes.js +0 -14
- package/lib/commands/make/backend/api-serializer.js +0 -15
- package/lib/steps/extenders/api-serializer.js +0 -77
- package/lib/steps/stubs/backend/api-controller.js +0 -65
- package/lib/steps/stubs/frontend/migration.js +0 -1
- package/php-subsystem/vendor/nikic/php-parser/.editorconfig +0 -9
- package/php-subsystem/vendor/nikic/php-parser/grammar/README.md +0 -27
- package/php-subsystem/vendor/nikic/php-parser/grammar/parser.template +0 -106
- package/php-subsystem/vendor/nikic/php-parser/grammar/php5.y +0 -1026
- package/php-subsystem/vendor/nikic/php-parser/grammar/php7.y +0 -1152
- package/php-subsystem/vendor/nikic/php-parser/grammar/phpyLang.php +0 -192
- package/php-subsystem/vendor/nikic/php-parser/grammar/rebuildParsers.php +0 -81
- package/php-subsystem/vendor/nikic/php-parser/grammar/tokens.template +0 -17
- package/php-subsystem/vendor/nikic/php-parser/grammar/tokens.y +0 -115
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/CoaleseEqualTokenEmulator.php +0 -47
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FlexibleDocStringEmulator.php +0 -76
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FnTokenEmulator.php +0 -23
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NumericLiteralSeparatorEmulator.php +0 -105
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Throw_.php +0 -30
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Parser/Multiple.php +0 -55
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Parser/Php5.php +0 -2630
- package/php-subsystem/vendor/nikic/php-parser/lib/PhpParser/Parser/Tokens.php +0 -145
- /package/{lib/steps/stubs/frontend/migration.d.ts → boilerplate/skeleton/extension/js/tests/integration/.gitkeep} +0 -0
- /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
|
-
|
|
16
|
-
{
|
|
17
|
-
const FIXUP_PREC_LEFT
|
|
18
|
-
const FIXUP_PREC_RIGHT
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
protected
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
Cast\
|
|
42
|
-
Cast\
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
BinaryOp\
|
|
52
|
-
BinaryOp\
|
|
53
|
-
BinaryOp\
|
|
54
|
-
BinaryOp\
|
|
55
|
-
BinaryOp\
|
|
56
|
-
BinaryOp\
|
|
57
|
-
BinaryOp\
|
|
58
|
-
BinaryOp\
|
|
59
|
-
BinaryOp\
|
|
60
|
-
BinaryOp\
|
|
61
|
-
BinaryOp\
|
|
62
|
-
BinaryOp\
|
|
63
|
-
BinaryOp\
|
|
64
|
-
BinaryOp\
|
|
65
|
-
BinaryOp\
|
|
66
|
-
BinaryOp\
|
|
67
|
-
BinaryOp\
|
|
68
|
-
BinaryOp\
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
AssignOp\
|
|
78
|
-
AssignOp\
|
|
79
|
-
AssignOp\
|
|
80
|
-
AssignOp\
|
|
81
|
-
AssignOp\
|
|
82
|
-
AssignOp\
|
|
83
|
-
AssignOp\
|
|
84
|
-
AssignOp\
|
|
85
|
-
AssignOp\
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
Expr\
|
|
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
|
-
|
|
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
|
|
103
|
-
protected $
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
/** @var
|
|
108
|
-
protected $
|
|
109
|
-
/** @var
|
|
110
|
-
protected $
|
|
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
|
|
113
|
-
*
|
|
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 $
|
|
138
|
+
protected array $removalMap;
|
|
116
139
|
/**
|
|
117
|
-
* @var
|
|
118
|
-
*
|
|
119
|
-
*
|
|
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 $
|
|
145
|
+
protected array $insertionMap;
|
|
122
146
|
/**
|
|
123
|
-
* @var
|
|
124
|
-
*
|
|
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 $
|
|
150
|
+
protected array $listInsertionMap;
|
|
151
|
+
|
|
128
152
|
/**
|
|
129
|
-
* @var string
|
|
130
|
-
* between elements of this list subnode.
|
|
153
|
+
* @var array<string, array{int|string|null, string, string}>
|
|
131
154
|
*/
|
|
132
|
-
protected $
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
*
|
|
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
|
-
* *
|
|
143
|
-
*
|
|
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
|
|
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->
|
|
181
|
+
$this->phpVersion = $options['phpVersion'] ?? PhpVersion::fromComponents(7, 4);
|
|
149
182
|
|
|
150
|
-
$
|
|
151
|
-
$this->
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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)
|
|
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)
|
|
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)
|
|
263
|
+
public function prettyPrintFile(array $stmts): string {
|
|
224
264
|
if (!$stmts) {
|
|
225
|
-
return "<?php
|
|
265
|
+
return "<?php" . $this->newline . $this->newline;
|
|
226
266
|
}
|
|
227
267
|
|
|
228
|
-
$p = "<?php
|
|
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)
|
|
258
|
-
*
|
|
259
|
-
* @param string $str
|
|
260
|
-
* @return string
|
|
297
|
+
* Handles (and removes) doc-string-end tokens.
|
|
261
298
|
*/
|
|
262
|
-
protected function handleMagicTokens(string $str)
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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
|
|
274
|
-
* @param bool
|
|
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)
|
|
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
|
|
307
|
-
* @param 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
|
|
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(
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
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
|
|
376
|
+
* @param string $class Node class of operator
|
|
325
377
|
* @param string $operatorString String representation of the operator
|
|
326
|
-
* @param 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)
|
|
331
|
-
|
|
332
|
-
|
|
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
|
|
406
|
+
* @param string $class Node class of operator
|
|
339
407
|
* @param string $operatorString String representation of the operator
|
|
340
|
-
* @param 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)
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
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
|
-
|
|
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
|
|
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 = '')
|
|
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)
|
|
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
|
|
413
|
-
* @param bool
|
|
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)
|
|
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)
|
|
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
|
|
471
|
-
* @param Node[] $origStmts
|
|
472
|
-
* @param
|
|
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)
|
|
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
|
|
550
|
+
$result = "<?php" . $this->newline . $this->pStmts($stmts, false);
|
|
499
551
|
}
|
|
500
552
|
|
|
501
|
-
return
|
|
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(
|
|
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, $
|
|
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
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
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
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
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
|
|
690
|
-
* @param
|
|
691
|
-
* @param int
|
|
692
|
-
* @param int
|
|
693
|
-
* @param string
|
|
694
|
-
* @param string
|
|
695
|
-
* @param null|int
|
|
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
|
|
701
|
-
string $
|
|
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 = $
|
|
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->
|
|
778
|
-
// We'd remove
|
|
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 (
|
|
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->
|
|
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->
|
|
877
|
-
// We'd remove
|
|
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
|
|
940
|
-
* @param Node
|
|
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
|
|
943
|
-
* @param int
|
|
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)
|
|
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
|
-
|
|
953
|
-
return $this->
|
|
954
|
-
|
|
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
|
|
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)
|
|
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
|
|
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)
|
|
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 &
|
|
1073
|
-
. ($modifiers &
|
|
1074
|
-
. ($modifiers &
|
|
1075
|
-
. ($modifiers &
|
|
1076
|
-
. ($modifiers &
|
|
1077
|
-
. ($modifiers &
|
|
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)
|
|
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)
|
|
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
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
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)
|
|
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)
|
|
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::
|
|
1163
|
-
'class' => self::
|
|
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::
|
|
1303
|
+
Expr\StaticCall::class => ['class' => self::FIXUP_STATIC_DEREF_LHS],
|
|
1172
1304
|
Expr\ArrayDimFetch::class => ['var' => self::FIXUP_DEREF_LHS],
|
|
1173
|
-
Expr\ClassConstFetch::class => [
|
|
1174
|
-
|
|
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::
|
|
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\
|
|
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::
|
|
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)
|
|
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
|
-
'
|
|
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
|
-
'
|
|
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)
|
|
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
|
-
'
|
|
1301
|
-
'Expr_ArrowFunction->returnType' => [')', false, '
|
|
1302
|
-
'Expr_Closure->returnType' => [')', false, '
|
|
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, '
|
|
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, '
|
|
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
|
-
'
|
|
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)
|
|
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
|
-
//'
|
|
1342
|
-
'
|
|
1343
|
-
'
|
|
1344
|
-
'
|
|
1345
|
-
'
|
|
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
|
-
'
|
|
1349
|
-
'
|
|
1350
|
-
'
|
|
1351
|
-
'
|
|
1352
|
-
'
|
|
1353
|
-
'
|
|
1354
|
-
'
|
|
1355
|
-
'
|
|
1356
|
-
'
|
|
1357
|
-
'
|
|
1358
|
-
'
|
|
1359
|
-
'
|
|
1360
|
-
'
|
|
1361
|
-
'
|
|
1362
|
-
'
|
|
1363
|
-
'
|
|
1364
|
-
'
|
|
1365
|
-
'
|
|
1366
|
-
'
|
|
1367
|
-
'
|
|
1368
|
-
'
|
|
1369
|
-
'
|
|
1370
|
-
'
|
|
1371
|
-
'
|
|
1372
|
-
'
|
|
1373
|
-
'
|
|
1374
|
-
'
|
|
1375
|
-
'
|
|
1376
|
-
'
|
|
1377
|
-
'
|
|
1378
|
-
'
|
|
1379
|
-
'
|
|
1380
|
-
'
|
|
1381
|
-
'
|
|
1382
|
-
'
|
|
1383
|
-
'
|
|
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
|
-
'
|
|
1387
|
-
'
|
|
1388
|
-
'
|
|
1389
|
-
'
|
|
1390
|
-
'
|
|
1391
|
-
'
|
|
1392
|
-
'
|
|
1393
|
-
'
|
|
1394
|
-
'
|
|
1395
|
-
'
|
|
1396
|
-
'
|
|
1397
|
-
'
|
|
1398
|
-
'
|
|
1399
|
-
'
|
|
1400
|
-
'
|
|
1401
|
-
'
|
|
1402
|
-
'
|
|
1403
|
-
'
|
|
1404
|
-
'
|
|
1405
|
-
'
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
'
|
|
1409
|
-
'
|
|
1410
|
-
'
|
|
1411
|
-
'
|
|
1412
|
-
'
|
|
1413
|
-
'
|
|
1414
|
-
'
|
|
1415
|
-
'
|
|
1416
|
-
'
|
|
1417
|
-
'
|
|
1418
|
-
'
|
|
1419
|
-
'
|
|
1420
|
-
'
|
|
1421
|
-
'
|
|
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)
|
|
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
|
-
'
|
|
1436
|
-
'
|
|
1437
|
-
'
|
|
1438
|
-
'
|
|
1439
|
-
'
|
|
1440
|
-
'
|
|
1441
|
-
'
|
|
1442
|
-
'
|
|
1443
|
-
'
|
|
1444
|
-
'
|
|
1445
|
-
'
|
|
1446
|
-
'
|
|
1447
|
-
'
|
|
1448
|
-
'
|
|
1449
|
-
'
|
|
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)
|
|
1632
|
+
protected function initializeModifierChangeMap(): void {
|
|
1633
|
+
if (isset($this->modifierChangeMap)) {
|
|
1634
|
+
return;
|
|
1635
|
+
}
|
|
1483
1636
|
|
|
1484
1637
|
$this->modifierChangeMap = [
|
|
1485
|
-
'
|
|
1486
|
-
'
|
|
1487
|
-
'
|
|
1488
|
-
'
|
|
1489
|
-
'
|
|
1490
|
-
|
|
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
|
-
//
|
|
1653
|
+
// UseItem->type
|
|
1498
1654
|
}
|
|
1499
1655
|
}
|