7
7
use PHPStan \Analyser \Scope ;
8
8
use PHPStan \Reflection \MethodReflection ;
9
9
use PHPStan \Symfony \ConsoleApplicationResolver ;
10
- use PHPStan \Type \BooleanType ;
11
10
use PHPStan \Type \Constant \ConstantBooleanType ;
12
11
use PHPStan \Type \DynamicMethodReturnTypeExtension ;
13
12
use PHPStan \Type \Type ;
@@ -36,22 +35,20 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
36
35
return $ methodReflection ->getName () === 'hasArgument ' ;
37
36
}
38
37
39
- public function getTypeFromMethodCall (MethodReflection $ methodReflection , MethodCall $ methodCall , Scope $ scope ): Type
38
+ public function getTypeFromMethodCall (MethodReflection $ methodReflection , MethodCall $ methodCall , Scope $ scope ): ? Type
40
39
{
41
- $ defaultReturnType = new BooleanType ();
42
-
43
40
if (!isset ($ methodCall ->getArgs ()[0 ])) {
44
- return $ defaultReturnType ;
41
+ return null ;
45
42
}
46
43
47
44
$ classReflection = $ scope ->getClassReflection ();
48
45
if ($ classReflection === null ) {
49
- return $ defaultReturnType ;
46
+ return null ;
50
47
}
51
48
52
49
$ argStrings = TypeUtils::getConstantStrings ($ scope ->getType ($ methodCall ->getArgs ()[0 ]->value ));
53
50
if (count ($ argStrings ) !== 1 ) {
54
- return $ defaultReturnType ;
51
+ return null ;
55
52
}
56
53
$ argName = $ argStrings [0 ]->getValue ();
57
54
@@ -67,11 +64,11 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
67
64
}
68
65
69
66
if (count ($ returnTypes ) === 0 ) {
70
- return $ defaultReturnType ;
67
+ return null ;
71
68
}
72
69
73
70
$ returnTypes = array_unique ($ returnTypes );
74
- return count ($ returnTypes ) === 1 ? new ConstantBooleanType ($ returnTypes [0 ]) : $ defaultReturnType ;
71
+ return count ($ returnTypes ) === 1 ? new ConstantBooleanType ($ returnTypes [0 ]) : null ;
75
72
}
76
73
77
74
}
0 commit comments