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