-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DX] [DI] Improve exception for invalid setter injection arguments #25663
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
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
Conversation
Come to think of it now - we could just also force-wrap the second argument into an array so the currently failing syntax also works. Don't see a reason why not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK as is for 3.4 IMHO
@nicolas-grekas before I rebase - what's your take on just force-wrapping the array. I think it's harmless convenience and it makes the exception obsolete. |
Alternative ways to write configuration create dead end for user experience (people need to learn two ways of doing things, so they can just read config from different people) |
ee2fea3
to
6850a22
Compare
Rebased. |
Thank you @curry684. |
… arguments (curry684) This PR was merged into the 3.4 branch. Discussion ---------- [DX] [DI] Improve exception for invalid setter injection arguments | Q | A | ------------- | --- | Branch? | 4.0 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | yes | License | MIT Improve the exception message for when you accidentally write setter injection wrong as I did too many times: ```yaml My\Logging\Service: calls: [ [ setLogger, "@logger" ] ] ``` Used to throw: > Type error: Argument 2 passed to Symfony\Component\DependencyInjection\Definition::addMethodCall() must be of the type array, object given, called in /var/www/project/vendor/symfony/dependency-injection/Loader/YamlFileLoader.php on line 457 Now throws: > The second parameter for function call "setLogger" must be an array of its arguments for service "My\Namespace\Service" in /var/www/project/config/services.yaml. Check your YAML syntax in /var/www/project/config/services.yaml (which is loaded in resource "/var/www/project/config/services.yaml"). (semi-offtopic: why isn't `LoggerAwareInterface` in the default autoconfigure for FrameworkExtension?) Commits ------- 6850a22 [DX] [DI] Improve exception for invalid setter injection arguments
Improve the exception message for when you accidentally write setter injection wrong as I did too many times:
Used to throw:
Now throws:
(semi-offtopic: why isn't
LoggerAwareInterface
in the default autoconfigure for FrameworkExtension?)