8000 [DI] Fix error when trying to resolve a DefinitionDecorator by nicolas-grekas · Pull Request #20543 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[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

Merged
merged 1 commit into from
Nov 17, 2016

Conversation

nicolas-grekas
Copy link
Member
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.

@@ -840,6 +840,10 @@ public function findDefinition($id)
*/
public function createService(Definition $definition, $id, $tryProxy = true)
{
if ($definition instanceof DefinitionDecorator) {
Copy link
Member

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)?

Copy link
Member Author

Choose a reason for hiding this comment

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

that way?

Copy link
Member

Choose a reason for hiding this comment

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

👍

@stof
Copy link
Member
stof commented Nov 17, 2016

👍

1 similar comment
@xabbuh
Copy link
Member
xabbuh commented Nov 17, 2016

👍

@@ -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)));
Copy link
Member

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

@fabpot
Copy link
Member
fabpot commented Nov 17, 2016

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 8e0da2f into symfony:2.7 Nov 17, 2016
fabpot added a commit that referenced this pull request Nov 17, 2016
…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
@nicolas-grekas nicolas-grekas deleted the warn-def-deco branch November 17, 2016 16:26
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.

6 participants
0