-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] Fix error when trying to resolve a DefinitionDecorator #20543
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
b654edd
to
37bfb16
Compare
@@ -840,6 +840,10 @@ public function findDefinition($id) | |||
*/ | |||
public function createService(Definition $definition, $id, $tryProxy = true) | |||
{ | |||
if ($definition instanceof DefinitionDecorator) { |
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.
What about checking this in a more generic way (i.e. forbidding all Definition
subclasses)?
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.
that way?
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.
👍
37bfb16
to
8e0da2f
Compare
👍 |
1 similar comment
👍 |
@@ -840,6 +840,10 @@ public function findDefinition($id) | |||
*/ | |||
public function createService(Definition $definition, $id, $tryProxy = true) | |||
{ | |||
if ('Symfony\Component\DependencyInjection\Definition' !== get_class($definition)) { | |||
throw new RuntimeException(sprintf('Constructing service "%s" from a %s is not supported at build time.', $id, get_class($definition))); |
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.
missing ""
around the second %s
Thank you @nicolas-grekas. |
…r (nicolas-grekas) This PR was merged into the 2.7 branch. Discussion ---------- [DI] Fix error when trying to resolve a DefinitionDecorator | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Instead of the currently obscure `ReflectionException: Class does not exist` message, let's throw a useful error message. Commits ------- 8e0da2f [DI] Fix error when trying to resolve a DefinitionDecorator
Instead of the currently obscure
ReflectionException: Class does not exist
message, let's throw a useful error message.