Skip to content

Conversation

@yoeunes
Copy link
Contributor

@yoeunes yoeunes commented Nov 22, 2025

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.

@nicolas-grekas
Copy link
Member

I added this because there is a competition between bindings and autowiring for Target attributes.
Maybe can have ResolveBindingsPass alias from the Target name before using the argument name?

@yoeunes yoeunes force-pushed the di-allow-binding-on-target branch from a9938cb to 8b68505 Compare November 22, 2025 15:17
@yoeunes yoeunes force-pushed the di-allow-binding-on-target branch from 8b68505 to 6fb5c67 Compare November 22, 2025 15:39
@yoeunes
Copy link
Contributor Author

yoeunes commented Nov 22, 2025

Hi @nicolas-grekas, I updated the logic as suggested to handle both cases:

  1. Priority: Look for a binding matching the #[Target] name.
  2. Fallback: Use the parameter name if no specific binding is found.

I added a test case covering both scenarios.

@nicolas-grekas
Copy link
Member

Thank you @yoeunes.

@nicolas-grekas nicolas-grekas merged commit 0a87f0a into symfony:7.4 Dec 5, 2025
12 checks passed
This was referenced Dec 7, 2025
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.

3 participants