File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change 4
4
5
5
use PhpParser \Node ;
6
6
use PhpParser \Node \Expr \FuncCall ;
7
+ use PHPStan \Analyser \ArgumentsNormalizer ;
7
8
use PHPStan \Analyser \Scope ;
9
+ use PHPStan \Reflection \ParametersAcceptorSelector ;
8
10
use PHPStan \Reflection \ReflectionProvider ;
9
11
use PHPStan \Rules \Rule ;
10
12
use PHPStan \Rules \RuleErrorBuilder ;
@@ -38,13 +40,28 @@ public function processNode(Node $node, Scope $scope): array
38
40
return [];
39
41
}
40
42
41
- $ functionName = $ this ->reflectionProvider ->resolveFunctionName ($ node ->name , $ scope );
43
+ if (!$ this ->reflectionProvider ->hasFunction ($ node ->name , $ scope )) {
44
+ return [];
45
+ }
46
+
47
+ $ functionReflection = $ this ->reflectionProvider ->getFunction ($ node ->name , $ scope );
48
+ if ($ functionReflection ->getName () !== 'array_filter ' ) {
49
+ return [];
50
+ }
51
+
52
+ $ parametersAcceptor = ParametersAcceptorSelector::selectFromArgs (
53
+ $ scope ,
54
+ $ node ->getArgs (),
55
+ $ functionReflection ->getVariants (),
56
+ $ functionReflection ->getNamedArgumentsVariants (),
57
+ );
42
58
43
- if ($ functionName === null || strtolower ($ functionName ) !== 'array_filter ' ) {
59
+ $ normalizedFuncCall = ArgumentsNormalizer::reorderFuncArguments ($ parametersAcceptor , $ node );
60
+ if ($ normalizedFuncCall === null ) {
44
61
return [];
45
62
}
46
63
47
- $ args = $ node ->getArgs ();
64
+ $ args = $ normalizedFuncCall ->getArgs ();
48
65
if (count ($ args ) !== 1 ) {
49
66
return [];
50
67
}
You can’t perform that action at this time.
0 commit comments