55namespace Rector \TypeDeclaration \Rector \ClassMethod ;
66
77use PhpParser \Node ;
8+ use PhpParser \Node \Arg ;
89use PhpParser \Node \Expr \ArrowFunction ;
910use PhpParser \Node \Expr \Closure ;
1011use PhpParser \Node \Expr \FuncCall ;
2223use Rector \BetterPhpDocParser \PhpDocInfo \PhpDocInfo ;
2324use Rector \BetterPhpDocParser \PhpDocInfo \PhpDocInfoFactory ;
2425use Rector \BetterPhpDocParser \PhpDocManipulator \PhpDocTypeChanger ;
25- use Rector \NodeAnalyzer \ArgsAnalyzer ;
2626use Rector \Rector \AbstractRector ;
2727use Rector \StaticTypeMapper \StaticTypeMapper ;
2828use Rector \TypeDeclaration \Enum \NativeFuncCallPositions ;
@@ -36,7 +36,6 @@ final class AddParamArrayDocblockBasedOnCallableNativeFuncCallRector extends Abs
3636{
3737 public function __construct (
3838 private readonly PhpDocInfoFactory $ phpDocInfoFactory ,
39- private readonly ArgsAnalyzer $ argsAnalyzer ,
4039 private readonly PhpDocTypeChanger $ phpDocTypeChanger ,
4140 private readonly StaticTypeMapper $ staticTypeMapper
4241 ) {
@@ -119,17 +118,18 @@ function (Node $subNode) use ($variableNamesWithArrayType, $node, &$paramsWithTy
119118 }
120119
121120 $ args = $ subNode ->getArgs ();
122- if ($ this ->argsAnalyzer ->hasNamedArg ($ args )) {
123- return null ;
124- }
125-
126121 if (count ($ args ) < 2 ) {
127122 return null ;
128123 }
129124
130125 $ funcCallName = (string ) $ this ->getName ($ subNode );
131126
132- $ arrayArgValue = $ args [NativeFuncCallPositions::ARRAY_AND_CALLBACK_POSITIONS [$ funcCallName ]['array ' ]]->value ;
127+ $ arrayArg = $ subNode ->getArg ('array ' , NativeFuncCallPositions::ARRAY_AND_CALLBACK_POSITIONS [$ funcCallName ]['array ' ]);
128+ if (! $ arrayArg instanceof Arg) {
129+ return null ;
130+ }
131+
132+ $ arrayArgValue = $ arrayArg ->value ;
133133 if (! $ arrayArgValue instanceof Variable) {
134134 return null ;
135135 }
@@ -146,8 +146,12 @@ function (Node $subNode) use ($variableNamesWithArrayType, $node, &$paramsWithTy
146146 return null ;
147147 }
148148
149- $ callbackArgValue = $ args [NativeFuncCallPositions::ARRAY_AND_CALLBACK_POSITIONS [$ funcCallName ]['callback ' ]]->value ;
149+ $ callbackArg = $ subNode ->getArg ('callback ' , NativeFuncCallPositions::ARRAY_AND_CALLBACK_POSITIONS [$ funcCallName ]['callback ' ]);
150+ if (! $ callbackArg instanceof Arg) {
151+ return null ;
152+ }
150153
154+ $ callbackArgValue = $ callbackArg ->value ;
151155 if (! $ callbackArgValue instanceof ArrowFunction && ! $ callbackArgValue instanceof Closure) {
152156 return null ;
153157 }
0 commit comments