Skip to content

Commit d8fb4ea

Browse files
committed
minor #17401 [2.7] Use is_subclass_of instead of reflection (Ener-Getick)
This PR was merged into the 2.7 branch. Discussion ---------- [2.7] Use is_subclass_of instead of reflection | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT Follows symfony/symfony#17400 > For performance reason, I replaced a reflection instantiation by ``is_subclass_of``. Commits ------- 5af5d06 Use is_subclass_of instead of reflection
2 parents 54847aa + 8cdaa52 commit d8fb4ea

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

DependencyInjection/Compiler/AddConsoleCommandPass.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ public function process(ContainerBuilder $container)
3737
}
3838

3939
$class = $container->getParameterBag()->resolveValue($definition->getClass());
40-
$r = new \ReflectionClass($class);
41-
if (!$r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command')) {
40+
if (!is_subclass_of($class, 'Symfony\\Component\\Console\\Command\\Command')) {
4241
throw new \InvalidArgumentException(sprintf('The service "%s" tagged "console.command" must be a subclass of "Symfony\\Component\\Console\\Command\\Command".', $id));
4342
}
4443
$container->setAlias('console.command.'.strtolower(str_replace('\\', '_', $class)), $id);

0 commit comments

Comments
 (0)