[Deprecation] Deprecate AutowireAttributeRector - #981
Merged
Conversation
The rule pairs constructor params with config service arguments by name and position, across every PHP config it finds. That guess is far-fetched and not reliable, and custom autowiring should be handled with care, one service at a time. Removes the rule body, its tests and the config service argument resolving that only served this rule.
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.
AutowireAttributeRectorscans every PHP config in a directory, collects service arguments, and then pairs them with constructor params by name and by position:That guess is far-fetched and not reliable. A positional match across configs the rule cannot tell apart lands an
#[Autowire]on the wrong param, and the attribute then silently wins over the config it was supposed to replace:final class SomeClass { public function __construct( + #[Autowire(param: 'timeout')] private int $timeout, + #[Autowire(env: 'APP_SECRET')] private string $secret, ) { } }Right when the names line up, wrong as soon as they do not. Custom autowiring should be handled with care, one service at a time - not guessed in bulk.
What
DeprecatedInterfaceand throws on use, same as [Deprecation] Deprecate SimplifyFormRenderingRector #975.ConfigServiceArgumentsResolver,SetServiceClassNameResolver,CollectServiceArgumentsNodeVisitor,ServiceArgumentsandNamedSimplePhpParser.ParameterBagToAutowireAttributeRectoris untouched - it reads the#[Autowire]target off an explicit$parameterBag->get('...')call, no guessing involved.