7
7
use PHPStan \Reflection \MethodReflection ;
8
8
use PHPStan \Type \DynamicMethodReturnTypeExtension ;
9
9
use PHPStan \Type \Generic \GenericObjectType ;
10
- use PHPStan \Type \IntersectionType ;
11
10
use PHPStan \Type \ObjectType ;
12
11
use PHPStan \Type \Type ;
13
12
use PHPUnit \Framework \MockObject \Builder \InvocationMocker ;
@@ -32,24 +31,15 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
32
31
public function getTypeFromMethodCall (MethodReflection $ methodReflection , MethodCall $ methodCall , Scope $ scope ): Type
33
32
{
34
33
$ 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;
46
36
}));
47
37
48
38
if (count ($ mockClasses ) !== 1 ) {
49
39
return new ObjectType (InvocationMocker::class);
50
40
}
51
41
52
- return new GenericObjectType (InvocationMocker::class, $ mockClasses );
42
+ return new GenericObjectType (InvocationMocker::class, [ new ObjectType ( $ mockClasses[ 0 ])] );
53
43
}
54
44
55
45
}
0 commit comments