Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit abc2da9

Browse files
Fix build
1 parent db436df commit abc2da9

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

‎src/Rules/PHPUnit/MockMethodCallRule.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use PhpParser\Node\Expr\MethodCall;
77
use PHPStan\Analyser\Scope;
88
use PHPStan\Rules\Rule;
9-
use PHPStan\Type\IntersectionType;
109
use PHPUnit\Framework\MockObject\Builder\InvocationMocker;
1110
use PHPUnit\Framework\MockObject\MockObject;
1211
use PHPUnit\Framework\MockObject\Stub;
@@ -51,8 +50,7 @@ public function processNode(Node $node, Scope $scope): array
5150
$type = $scope->getType($node->var);
5251

5352
if (
54-
$type instanceof IntersectionType
55-
&& (
53+
(
5654
in_array(MockObject::class, $type->getObjectClassNames(), true)
5755
|| in_array(Stub::class, $type->getObjectClassNames(), true)
5856
)

‎src/Type/PHPUnit/MockObjectDynamicReturnTypeExtension.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use PHPStan\Reflection\MethodReflection;
88
use PHPStan\Type\DynamicMethodReturnTypeExtension;
99
use PHPStan\Type\Generic\GenericObjectType;
10-
use PHPStan\Type\IntersectionType;
1110
use PHPStan\Type\ObjectType;
1211
use PHPStan\Type\Type;
1312
use PHPUnit\Framework\MockObject\Builder\InvocationMocker;
@@ -32,24 +31,15 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
3231
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
3332
{
3433
$type = $scope->getType($methodCall->var);
35-
if (!($type instanceof IntersectionType)) {
36-
return new ObjectType(InvocationMocker::class);
37-
}
38-
39-
$mockClasses = array_values(array_filter($type->getTypes(), static function (Type $type): bool {
40-
$classNames = $type->getObjectClassNames();
41-
if (count($classNames) !== 1) {
42-
return true;
43-
}
44-
45-
return $classNames[0] !== MockObject::class;
34+
$mockClasses = array_values(array_filter($type->getObjectClassNames(), static function (string $class): bool {
35+
return $class !== MockObject::class;
4636
}));
4737

4838
if (count($mockClasses) !== 1) {
4939
return new ObjectType(InvocationMocker::class);
5040
}
5141

52-
return new GenericObjectType(InvocationMocker::class, $mockClasses);
42+
return new GenericObjectType(InvocationMocker::class, [newObjectType($mockClasses[0])]);
5343
}
5444

5545
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /