Skip to content

Conversation

@nicolas-grekas
Copy link
Member

Q A
Branch? 7.4
Bug fix? no
New feature? yes
Deprecations? no
Issues -
License MIT

This makes the API simpler and fixes debug:autowiring, which now displays e.g.:

 Symfony\Component\Workflow\WorkflowInterface $commentStateMachine - target:comment - alias:state_machine.comment

if ($container->hasAlias($internalAliasId)) {
$container->getAlias($internalAliasId)->setDeprecated('symfony/framework-bundle', '7.3', \sprintf('The "%%alias_id%%" autowiring alias is deprecated and will be removed in 8.0, use "%s $%s" instead.', RateLimiterFactoryInterface::class, (new Target($name.'.limiter'))->getParsedName()));
}
$factoryAlias->setDeprecated('symfony/framework-bundle', '7.3', 'The "%alias_id%" autowiring alias is deprecated and will be removed in 8.0, use "RateLimiterFactoryInterface" instead.');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to use a short RateLimiterFactoryInterface, that's the only thing that one needs to change when upgrading.

@nicolas-grekas
Copy link
Member Author

Status: needs work

This creates a convention that AutowirePass cannot handle at the moment.

@nicolas-grekas nicolas-grekas merged commit a7bd15e into symfony:7.4 Jun 27, 2025
9 of 11 checks passed
@nicolas-grekas nicolas-grekas deleted the di-target branch June 30, 2025 12:23
This was referenced Oct 27, 2025
nicolas-grekas added a commit that referenced this pull request Dec 5, 2025
…with #[Target] (yoeunes)

This PR was merged into the 7.4 branch.

Discussion
----------

[DependencyInjection] Allow manual bindings on parameters with #[Target]

| Q             | A
| ------------- | ---
| Branch?       | 7.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | -
| License       | MIT

PR #60910 added a check in `ResolveBindingsPass` that skips parameters with the `#[Target]` attribute.

This prevents users from manually overriding values via `bind` (or `_defaults`) and causes `"unused binding"` exceptions, even when the binding matches the parameter name.

`Symfony\Component\DependencyInjection\Exception\InvalidArgumentException: A binding is configured for an argument named "$arg" for service "service", but no corresponding argument has been found. It may be unused and should be removed, or it may have a typo.`

Commits
-------

6fb5c67 [DependencyInjection] Allow manual bindings on parameters with #[Target]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants