Skip to content

Commit

Permalink
Get rid of instanceof TypeWithClassName in `MissingCheckedException…
Browse files Browse the repository at this point in the history
…InThrowsCheck`
  • Loading branch information
herndlm authored and ondrejmirtes committed Jan 16, 2023
1 parent b724d3a commit 6390e7a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Rules/Exceptions/MissingCheckedExceptionInThrowsCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

use PhpParser\Node;
use PHPStan\Analyser\ThrowPoint;
use PHPStan\TrinaryLogic;
use PHPStan\Type\NeverType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
use PHPStan\Type\TypeUtils;
use PHPStan\Type\TypeWithClassName;
use PHPStan\Type\VerbosityLevel;
use Throwable;

Expand Down Expand Up @@ -43,10 +43,11 @@ public function check(?Type $throwType, array $throwPoints): array
continue;
}

if (
$throwPointType instanceof TypeWithClassName
&& !$this->exceptionTypeResolver->isCheckedException($throwPointType->getClassName(), $throwPoint->getScope())
) {
$isCheckedException = TrinaryLogic::createNo()->lazyOr(
$throwPointType->getObjectClassNames(),
fn (string $objectClassName) => TrinaryLogic::createFromBoolean($this->exceptionTypeResolver->isCheckedException($objectClassName, $throwPoint->getScope())),
);
if ($isCheckedException->no()) {
continue;
}

Expand Down

0 comments on commit 6390e7a

Please sign in to comment.