Skip to content

Commit

Permalink
MockObjectTypeNodeResolverExtension - prioritize UnionType of MockObj…
Browse files Browse the repository at this point in the history
…ect|Foo if the intersection is NeverType
  • Loading branch information
ondrejmirtes committed Apr 13, 2020
1 parent e4552ce commit 3e823ff
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/PhpDoc/PHPUnit/MockObjectTypeNodeResolverExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use PHPStan\PhpDoc\TypeNodeResolverExtension;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode;
use PHPStan\Type\NeverType;
use PHPStan\Type\Type;
use PHPStan\Type\TypeWithClassName;

Expand Down Expand Up @@ -44,7 +45,10 @@ public function resolve(TypeNode $typeNode, \PHPStan\Analyser\NameScope $nameSco
}

if (array_key_exists($type->getClassName(), $mockClassNames)) {
return \PHPStan\Type\TypeCombinator::intersect(...$types);
$resultType = \PHPStan\Type\TypeCombinator::intersect(...$types);
if (!$resultType instanceof NeverType) {
return $resultType;
}
}
}

Expand Down

0 comments on commit 3e823ff

Please sign in to comment.