-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] Improve error message for non-autowirable scalar argument #26856
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
Conversation
nicolas-grekas
commented
Apr 7, 2018
Q | A |
---|---|
Branch? | 3.4 |
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #26838 |
License | MIT |
Doc PR | - |
if ($type = ProxyHelper::getTypeHint($reflectionMethod, $parameter, false)) { | ||
$message = 'Cannot autowire service "%s": argument "%s $%s" of method "%s()" must be given a value explicitly.'; | ||
} else { | ||
$message = 'Cannot autowire service "%s": argument "%s$%s" of method "%s()" must have a type-hint or be given a value explicitly.'; |
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.
just adding a type hint does not neccessarily help like string
. So maybe it should say something like "must have a known type-hint".
3f4217a
to
d9215f7
Compare
message updated |
d9215f7
to
607f54f
Compare
@@ -233,7 +233,10 @@ private function autowireMethod(\ReflectionFunctionAbstract $reflectionMethod, a | |||
if ($parameter->isOptional()) { | |||
continue; | |||
} | |||
throw new AutowiringFailedException($this->currentId, sprintf('Cannot autowire service "%s": argument "$%s" of method "%s()" must have a type-hint or be given a value explicitly.', $this->currentId, $parameter->name, $class !== $this->currentId ? $class.'::'.$method : $method)); | |||
$type = ProxyHelper::getTypeHint($reflectionMethod, $parameter, false); | |||
$type = $type ? sprintf('is type-hinted "%s"', $type) : 'has not type-hint'; |
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.
typo: has no type-hint
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.
fixed
607f54f
to
1c9e5f3
Compare
1c9e5f3
to
7f39811
Compare
Thank you @nicolas-grekas. |
…gument (nicolas-grekas) This PR was merged into the 3.4 branch. Discussion ---------- [DI] Improve error message for non-autowirable scalar argument | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #26838 | License | MIT | Doc PR | - Commits ------- 7f39811 [DI] Improve error message for non-autowirable scalar argument