Use is_subclass_of instead of reflection

This commit is contained in:
Ener-Getick 2016-01-16 14:49:05 +01:00
parent 8d7b19fbbe
commit 5af5d06f2e

View File

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