Skip to content

[DependencyInjection] Improve reporting named autowiring aliases #50718

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 13, 2023

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Jun 20, 2023

Q A
Branch? 6.4
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR -

This PR started as a fix of #48707 to improve the error message reported when #[Target] is used with an invalid target, and ended up with many other related improvements:

  • Allow using #[Target] with no arguments. This has the effect of throwing an exception if the name of the argument that has the attribute doesn't match a named autowiring alias.

  • Improve the error message when a target doesn't match:

image

  • Improve debug:autowiring to display the target name to use with #[Target]:

image


public function __construct(string $name)
public function getParsedName(): string
Copy link
Member

Choose a reason for hiding this comment

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

should we even have it as a public method if calling it directly would be a mistake ?

Copy link
Member Author

@nicolas-grekas nicolas-grekas Jun 20, 2023

Choose a reason for hiding this comment

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

I think yes. Calling it directly works, but only if you gave a name to the constructor.

@nicolas-grekas nicolas-grekas force-pushed the di-target++ branch 4 times, most recently from d1abfdb to 741a50c Compare June 21, 2023 07:45
@lyrixx
Copy link
Member

lyrixx commented Jun 21, 2023

i like the feature a lot. Thanks

@fabpot
Copy link
Member

fabpot commented Jul 13, 2023

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 6a65ebd into symfony:6.4 Jul 13, 2023
@nicolas-grekas nicolas-grekas deleted the di-target++ branch July 25, 2023 15:45
This was referenced Oct 21, 2023
nicolas-grekas added a commit that referenced this pull request Dec 1, 2023
… that contain underscores (nicolas-grekas)

This PR was merged into the 6.4 branch.

Discussion
----------

[DependencyInjection] Fix parsing named autowiring aliases that contain underscores

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #52815
| License       | MIT

Fixing a regression introduced in #50718

Commits
-------

69a115c [DependencyInjection] Fix parsing named autowiring aliases that contain underscores
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.

5 participants