Skip to content

Commit fb817e2

Browse files
committed
Improve compatibility with PHPStan 1.0
1 parent 3707cff commit fb817e2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Symfony/ConsoleApplicationResolver.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PHPStan\Reflection\ClassReflection;
66
use PHPStan\ShouldNotHappenException;
77
use PHPStan\Type\ObjectType;
8+
use Symfony\Component\Console\Command\Command;
89
use function file_exists;
910
use function get_class;
1011
use function is_readable;
@@ -57,8 +58,12 @@ public function findCommands(ClassReflection $classReflection): array
5758
$commandClass = new ObjectType(get_class($command));
5859
$isLazyCommand = (new ObjectType('Symfony\Component\Console\Command\LazyCommand'))->isSuperTypeOf($commandClass)->yes();
5960

60-
if ($isLazyCommand && method_exists($command, 'getCommand') && !$classType->isSuperTypeOf(new ObjectType(get_class($command->getCommand())))->yes()) {
61-
continue;
61+
if ($isLazyCommand && method_exists($command, 'getCommand')) {
62+
/** @var Command $wrappedCommand */
63+
$wrappedCommand = $command->getCommand();
64+
if (!$classType->isSuperTypeOf(new ObjectType(get_class($wrappedCommand)))->yes()) {
65+
continue;
66+
}
6267
}
6368

6469
if (!$isLazyCommand && !$classType->isSuperTypeOf($commandClass)->yes()) {

0 commit comments

Comments
 (0)