Skip to content

Commit 7081a7e

Browse files
authored
ForbidUnusedExceptionRule: remove is_a function (#10)
ForbidUnusedExceptionRule: remove is_a function (unreliable in newer phpstan versions)
1 parent eee2284 commit 7081a7e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Rule/ForbidUnusedExceptionRule.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use PHPStan\Type\TypeWithClassName;
1515
use ShipMonk\PHPStan\Visitor\UnusedExceptionVisitor;
1616
use Throwable;
17-
use function is_a;
1817

1918
/**
2019
* @implements Rule<Expr>
@@ -88,7 +87,9 @@ private function isException(Expr $node, Scope $scope): bool
8887
{
8988
$type = $scope->getType($node);
9089

91-
return $type instanceof TypeWithClassName && is_a($type->getClassName(), Throwable::class, true);
90+
return $type instanceof TypeWithClassName
91+
&& $type->getClassReflection() !== null
92+
&& $type->getClassReflection()->isSubclassOf(Throwable::class);
9293
}
9394

9495
private function isUsed(Expr $node): bool

0 commit comments

Comments
 (0)