Skip to content

Symfony: add support for additional magical calls#317

Merged
janedbal merged 9 commits intomasterfrom
symfony-additional-magic-calls
Mar 23, 2026
Merged

Symfony: add support for additional magical calls#317
janedbal merged 9 commits intomasterfrom
symfony-additional-magic-calls

Conversation

@janedbal
Copy link
Copy Markdown
Member

  • #[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

@janedbal janedbal force-pushed the symfony-additional-magic-calls branch 2 times, most recently from c071d0c to 2f135be Compare March 23, 2026 14:57
@janedbal janedbal marked this pull request as ready for review March 23, 2026 15:04
- #[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
@janedbal janedbal force-pushed the symfony-additional-magic-calls branch from fbcfdfa to 44958fd Compare March 23, 2026 15:07
Handle both `['setLogger']` and `['setLogger' => ['@logger']]` formats
for the calls parameter, matching what Symfony's YamlFileLoader accepts.

Co-Authored-By: Claude Code
@janedbal janedbal merged commit 2b4b40d into master Mar 23, 2026
32 checks passed
@janedbal janedbal deleted the symfony-additional-magic-calls branch March 23, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant