Navigation Menu

Skip to content

Commit

Permalink
bug #19842 [FrameworkBundle] Check for class existence before is_subc…
Browse files Browse the repository at this point in the history
…lass_of (chalasr)

This PR was merged into the 2.7 branch.

Discussion
----------

[FrameworkBundle] Check for class existence before is_subclass_of

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Same as #19342

Commits
-------

8a9e0f5 [FrameworkBundle] Check for class existence before is_subclass_of
  • Loading branch information
nicolas-grekas committed Sep 6, 2016
2 parents 8a9b287 + 8a9e0f5 commit 8693611
Showing 1 changed file with 4 additions and 0 deletions.
Expand Up @@ -38,6 +38,10 @@ public function process(ContainerBuilder $container)

$class = $container->getParameterBag()->resolveValue($definition->getClass());
if (!is_subclass_of($class, 'Symfony\\Component\\Console\\Command\\Command')) {
if (!class_exists($class, false)) {
throw new \InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $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);
Expand Down

1 comment on commit 8693611

@dice4x4
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In PR title you say "before is_subclass_of" but in code you check it after. What's wrong?

Please sign in to comment.