Repository navigation
Add migrate:neon2attributes command and extend attribute services - #6920
Merged
Merged
Conversation
A single `if` string that expands to a list of conditions, like strictRules.booleansInLoopConditions, now requires all of them to be met. It was wrapped in another list and the non-empty array counted as met. Amp-Thread-ID: https://ampcode.com/threads/T-01a19cd4-be31-75b4-bd15-67786eff5983
…r autoload rules Classes declared in the attributeServicesDirectories are loaded with class_exists(), so any autoloader works, including --autoload-file. Each class is autoloaded once, which avoids redeclaring classes whose file does not match its PSR-4 path. Amp-Thread-ID: https://ampcode.com/threads/T-01a19cd4-be31-75b4-bd15-67786eff5983
Replaces the rules, services and conditionalTags entries of the project's non-vendor NEON config files with attributes on the service classes in attributeServicesDirectories. Entries the attributes cannot express stay in the config files and are reported with the reason. Amp-Thread-ID: https://ampcode.com/threads/T-01a19cd4-be31-75b4-bd15-67786eff5983
Class::CONST, ::CONST, Enum::Case and @service strings become constants and references, also inside the value of a referenced parameter. Amp-Thread-ID: https://ampcode.com/threads/T-01a19cd4-be31-75b4-bd15-67786eff5983
… class class: FooInterface with factory: Foo becomes #[AutowiredService(as: FooInterface::class)] on Foo. Amp-Thread-ID: https://ampcode.com/threads/T-01a19cd4-be31-75b4-bd15-67786eff5983
…face] and the extensionInterfaces section Attribute services implementing these interfaces get the tag automatically, and conditionalTags and the tag validation accept the configured tags. Amp-Thread-ID: https://ampcode.com/threads/T-01a19cd4-be31-75b4-bd15-67786eff5983
Like class: Interface, factory: Implementation in NEON, the service is no longer autowired as the implementation class too. Amp-Thread-ID: https://ampcode.com/threads/T-01a19cd4-be31-75b4-bd15-67786eff5983
…on of config.neon Amp-Thread-ID: https://ampcode.com/threads/T-01a19cd4-be31-75b4-bd15-67786eff5983
A separate process re-includes the files of the parent process, which triggers deprecations on PHP 8.6, and PHPUnit versions disagree on how to disable that. Amp-Thread-ID: https://ampcode.com/threads/T-01a19cd4-be31-75b4-bd15-67786eff5983
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the
migrate:neon2attributescommand, which convertsservices,rules,conditionalTagsandextensionInterfacesentries in a project's NEON config files to the DI attributes, and extends the attributes so they cover more NEON cases.Attribute changes:
#[Conditional]with a parameter holding a list is evaluated likeconditionalTags.class_exists()), not Composer autoload rules.#[AutowiredParameter]values go through Nette'sfilterArguments()like NEON arguments (Class::CONST,@service).factory:in#[AutowiredService]and#[NonAutowiredService]accepts a static methodFoo::create.#[AutowiredService(as:)]becomes the service type, likeclass: Interface, factory: Implementationin NEON. The service is no longer also autowired as the implementation class.#[ExtensionInterface(tag:)](now@api) or the newextensionInterfaces:section. Auto-tagging,conditionalTagsand tag validation use the merged mapping.The command:
analyse, plusextra.phpstan.includesfromcomposer.json.Parity testing: each project was migrated, then its compiled DI container was compared before and after, with the default config and with every
conditionalTagsboolean flipped. Extensions were also compared on a level-8 analysis. All 10 1st-party extensions, 78 Packagist packages and 2 private apps came out identical. The remaining differences:tagged()lists can change order. This is documented.-c.