-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] Fix checking for interfaces in ContainerBuilder::getReflectionClass() #58822
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
[DependencyInjection] Fix checking for interfaces in ContainerBuilder::getReflectionClass() #58822
Conversation
Hey! Thanks for your PR. You are targeting branch "7.2" but it seems your PR description refers to branch "5.4 or 7.2, TBD". Cheers! Carsonbot |
This looks like a bugfix to me. Please target 5.4. |
6f2be11
to
1c3690b
Compare
Let's see if there is consensus that this is a bug fix. |
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.
LGTM after some minor changes
@@ -369,7 +369,7 @@ public function getReflectionClass(?string $class, bool $throw = true): ?\Reflec | |||
$resource = new ClassExistenceResource($class, false); | |||
$classReflector = $resource->isFresh(0) ? false : new \ReflectionClass($class); | |||
} else { | |||
$classReflector = class_exists($class) ? new \ReflectionClass($class) : false; | |||
$classReflector = (class_exists($class) || interface_exists($class)) ? new \ReflectionClass($class) : false; |
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.
$classReflector = (class_exists($class) || interface_exists($class)) ? new \ReflectionClass($class) : false; | |
$classReflector = class_exists($class) || interface_exists($class, false) ? new \ReflectionClass($class) : false; |
…ainerBuilder::getReflectionClass().
1c3690b
to
6166e8f
Compare
Thank you @donquixote. |
Currently,
ContainerBuilder::getReflectionClass()
supports interfaces only ifsymfony/config
package is present.With this fix, it will do so without
symfony/config
.Not sure how to do this.
All tests run in the monorepo, with all packages present, so
class_exists(ClassExistenceResource::class)
will always be TRUE.To make this testable, we should make the condition dependent on resource tracking.
This is TBD.
This change would enable autowire for some services where this was previously not the case.