10000 bug #19842 [FrameworkBundle] Check for class existence before is_subc… · symfony/symfony@8693611 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8693611

Browse files
bug #19842 [FrameworkBundle] Check for class existence before is_subclass_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
2 parents 8a9b287 + 8a9e0f5 commit 8693611

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddConsoleCommandPass.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ public function process(ContainerBuilder $container)
3838

3939
$class = $container->getParameterBag()->resolveValue($definition->getClass());
4040
if (!is_subclass_of($class, 'Symfony\\Component\\Console\\Command\\Command')) {
41+
if (!class_exists($class, false)) {
42+
throw new \InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
43+
}
44+
4145
throw new \InvalidArgumentException(sprintf('The service "%s" tagged "console.command" must be a subclass of "Symfony\\Component\\Console\\Command\\Command".', $id));
4246
}
4347
$container->setAlias('console.command.'.strtolower(str_replace('\\', '_', $class)), $id);

0 commit comments

Comments
 (0)
0