Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Exception when reflecting console Application class. #8200

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

Closed
jmalloc opened this issue Jun 4, 2013 · 5 comments
Closed

Exception when reflecting console Application class. #8200

jmalloc opened this issue Jun 4, 2013 · 5 comments

Comments

@jmalloc
Copy link

jmalloc commented Jun 4, 2013

The Console\Application::setDispatcher() method added in PR #7466 references EventDispatcherInterface as a type hint, however symfony/event-dispatcher is not listed as a runtime Composer dependency.

This has caused a BC breakage when using reflection on the console Application class, in the form of the following exception:

ReflectionException: Class Symfony\Component\EventDispatcher\EventDispatcherInterface does not exist

I'm not sure how this should be fixed, two possible solutions come to mind:

  • Promote symfony/event-dispatcher from require-dev to require
  • Do not use a type-hint on Application::setDispatcher()

As a workaround we've manually added symfony/event-dispatcher to our project's composer.json, but this does not feel like a good solution as our app does not use the event features at all.

@stof
Copy link
Member

stof commented Jun 4, 2013

It is an optional dependency of the component as the dispatcher is optional (you don't need to set a dispatcher to use the application). this is why the component is listed in the suggestions.

@jmalloc
Copy link
Author

jmalloc commented Jun 5, 2013

Oh yes, I can see that setting the dispatcher is optional to the core functionality, but we are not using the event features and as a result of this change a previously working application has broken.

It's definitely not a huge problem, as adding event-dispatcher as a dependency has gotten us going again, but I do believe it's harmful to shift the responsibility of managing these dependencies to the end-project. Just my 2c :)

@Tobion
Copy link
Contributor

Tobion commented Jun 5, 2013

Well, that's the whole point of optional dependencies. That you need to activate them when u need them which is apparently the case when doing reflection.

@fabpot
Copy link
Member

fabpot commented Jun 13, 2013

Indeed, I did not anticipate the BC break when using PHP reflection. Sorry for the inconvenience, but unfortunately, I don't see what we can do to "fix" this.

@fabpot fabpot closed this as completed Jun 13, 2013
@Tobion
Copy link
Contributor

Tobion commented Jun 13, 2013

Well, one could argue that ANY change to class is a bc break when using reflection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants