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 44
55use PhpParser \Node ;
66use PhpParser \Node \Expr \FuncCall ;
7+ use PHPStan \Analyser \ArgumentsNormalizer ;
78use PHPStan \Analyser \Scope ;
9+ use PHPStan \Reflection \ParametersAcceptorSelector ;
810use PHPStan \Reflection \ReflectionProvider ;
911use PHPStan \Rules \Rule ;
1012use PHPStan \Rules \RuleErrorBuilder ;
@@ -38,13 +40,28 @@ public function processNode(Node $node, Scope $scope): array
3840 return [];
3941 }
4042
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+ );
4258
43- if ($ functionName === null || strtolower ($ functionName ) !== 'array_filter ' ) {
59+ $ normalizedFuncCall = ArgumentsNormalizer::reorderFuncArguments ($ parametersAcceptor , $ node );
60+ if ($ normalizedFuncCall === null ) {
4461 return [];
4562 }
4663
47- $ args = $ node ->getArgs ();
64+ $ args = $ normalizedFuncCall ->getArgs ();
4865 if (count ($ args ) !== 1 ) {
4966 return [];
5067 }
You can’t perform that action at this time.
0 commit comments