10000 bug #58822 [DependencyInjection] Fix checking for interfaces in Conta… · symfony/symfony@cf20e09 · GitHub
[go: up one dir, main page]

Skip to content

Commit cf20e09

Browse files
bug #58822 [DependencyInjection] Fix checking for interfaces in ContainerBuilder::getReflectionClass() (donquixote)
This PR was merged into the 5.4 branch. Discussion ---------- [DependencyInjection] Fix checking for interfaces in ContainerBuilder::getReflectionClass() | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #58821. | License | MIT Currently, `ContainerBuilder::getReflectionClass()` supports interfaces only if `symfony/config` package is present. With this fix, it will do so without `symfony/config`. > Always add tests and ensure they pass. 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. > Never break backward compatibility (see https://symfony.com/bc). This is TBD. This change would enable autowire for some services where this was previously not the case. Commits ------- 6166e8f Issue #58821: [DependencyInjection] Support interfaces in ContainerBuilder::getReflectionClass().
2 parents c098762 + 6166e8f commit cf20e09

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ public function getReflectionClass(?string $class, bool $throw = true): ?\Reflec
369369
$resource = new ClassExistenceResource($class, false);
370370
$classReflector = $resource->isFresh(0) ? false : new \ReflectionClass($class);
371371
} else {
372-
$classReflector = class_exists($class) ? new \ReflectionClass($class) : false;
372+
$classReflector = class_exists($class) || interface_exists($class, false) ? new \ReflectionClass($class) : false;
373373
}
374374
} catch (\ReflectionException $e) {
375375
if ($throw) {

0 commit comments

Comments
 (0)
0