Skip to content

Commit

Permalink
ApiInstanceofRule - allow instanceof PHPStan\Type\Type
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jun 17, 2022
1 parent cc3cf88 commit 4482fe4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Rules/Api/ApiInstanceofRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function processNode(Node $node, Scope $scope): array
*/
private function processCoveredClass(Node\Expr\Instanceof_ $node, Scope $scope, ClassReflection $classReflection): array
{
if ($classReflection->isSubclassOf(Type::class)) {
if ($classReflection->getName() === Type::class || $classReflection->isSubclassOf(Type::class)) {
return [];
}

Expand Down
7 changes: 7 additions & 0 deletions tests/PHPStan/Rules/Api/data/instanceof-out-of-phpstan.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,11 @@ public function doBar(Scope $scope): void
}
}

public function doBaz($mixed): void
{
if ($mixed instanceof Type) {

}
}

}

0 comments on commit 4482fe4

Please sign in to comment.