6
6
use PHPStan \Analyser \Scope ;
7
7
use PHPStan \Php \PhpVersion ;
8
8
use PHPStan \Reflection \FunctionReflection ;
9
- use PHPStan \Reflection \ParametersAcceptorSelector ;
10
9
use PHPStan \ShouldNotHappenException ;
11
10
use PHPStan \TrinaryLogic ;
12
11
use PHPStan \Type \Accessory \AccessoryArrayListType ;
@@ -44,12 +43,10 @@ public function isFunctionSupported(FunctionReflection $functionReflection): boo
44
43
return in_array ($ functionReflection ->getName (), ['str_split ' , 'mb_str_split ' ], true );
45
44
}
46
45
47
- public function getTypeFromFunctionCall (FunctionReflection $ functionReflection , FuncCall $ functionCall , Scope $ scope ): Type
46
+ public function getTypeFromFunctionCall (FunctionReflection $ functionReflection , FuncCall $ functionCall , Scope $ scope ): ? Type
48
47
{
49
- $ defaultReturnType = ParametersAcceptorSelector::selectSingle ($ functionReflection ->getVariants ())->getReturnType ();
50
-
51
48
if (count ($ functionCall ->getArgs ()) < 1 ) {
52
- return $ defaultReturnType ;
49
+ return null ;
53
50
}
54
51
55
52
if (count ($ functionCall ->getArgs ()) >= 2 ) {
@@ -71,7 +68,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
71
68
$ values = array_unique (array_map (static fn (ConstantStringType $ encoding ): string => $ encoding ->getValue (), $ strings ));
72
69
73
70
if (count ($ values ) !== 1 ) {
74
- return $ defaultReturnType ;
71
+ return null ;
75
72
}
76
73
77
74
$ encoding = $ values [0 ];
@@ -84,7 +81,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
84
81
}
85
82
86
83
if (!isset ($ splitLength )) {
87
- return $ defaultReturnType ;
84
+ return null ;
88
85
}
89
86
90
87
$ stringType = $ scope ->getType ($ functionCall ->getArgs ()[0 ]->value );
0 commit comments