Symfony: add support for additional magical calls#317
Merged
Conversation
c071d0c to
2f135be
Compare
- #[Autoconfigure(constructor: '...')] named static factory methods - #[Autoconfigure(calls: [...])] method calls after instantiation - #[TaggedIterator] and #[TaggedLocator] (deprecated predecessors of AutowireIterator/AutowireLocator) - #[AutowireCallable(service: ..., method: '...')] method references - YAML !php/enum syntax for enum case references - #[Required] on properties (not just methods) - #[AsSchedule], #[AsCronTask], #[AsPeriodicTask] scheduler attributes
AutowireCallable was introduced in Symfony 6.3. On PHP 8.0 only Symfony 5.4/6.0 is available, so the attribute class does not exist.
The DIC writes to the property, but reads come from user code and are already tracked by static analysis. Emitting both would hide genuinely unread properties.
AutowireLocator uses 'services' (string|array), while TaggedLocator uses 'tag' (string) like AutowireIterator/TaggedIterator. Handle TaggedLocator alongside the iterator variants instead of mixing argument keys with a fallback.
Move #[Autoconfigure(constructor)] and #[Autoconfigure(calls)] detection from per-method shouldMarkAsUsed() to class-level getMethodUsagesFromReflection(), where class attributes are iterated once and usages emitted directly.
Replace inline attribute stubs with the real vendor classes. Guard the scheduler test with requiresPackage check.
Use AccessType enum, named arguments, and trailing commas to match the codebase style after the PHP 8.1+ migration. Co-Authored-By: Claude Code
Co-Authored-By: Claude Code
fbcfdfa to
44958fd
Compare
Handle both `['setLogger']` and `['setLogger' => ['@logger']]` formats for the calls parameter, matching what Symfony's YamlFileLoader accepts. Co-Authored-By: Claude Code
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.
#[Autoconfigure(constructor: '...')]named static factory methods#[Autoconfigure(calls: [...])]method calls after instantiation#[TaggedIterator]and#[TaggedLocator](deprecated predecessors ofAutowireIterator/AutowireLocator)#[AutowireCallable(service: ..., method: '...')]method references!php/enumsyntax for enum case references#[Required]on properties (not just methods)#[AsSchedule],#[AsCronTask],#[AsPeriodicTask]scheduler attributes