Skip to content

Commit 3e823ff

Browse files
committed
MockObjectTypeNodeResolverExtension - prioritize UnionType of MockObject|Foo if the intersection is NeverType
1 parent e4552ce commit 3e823ff

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/PhpDoc/PHPUnit/MockObjectTypeNodeResolverExtension.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use PHPStan\PhpDoc\TypeNodeResolverExtension;
88
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
99
use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode;
10+
use PHPStan\Type\NeverType;
1011
use PHPStan\Type\Type;
1112
use PHPStan\Type\TypeWithClassName;
1213

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

4647
if (array_key_exists($type->getClassName(), $mockClassNames)) {
47-
return \PHPStan\Type\TypeCombinator::intersect(...$types);
48+
$resultType = \PHPStan\Type\TypeCombinator::intersect(...$types);
49+
if (!$resultType instanceof NeverType) {
50+
return $resultType;
51+
}
4852
}
4953
}
5054

0 commit comments

Comments
 (0)