@@ -152,7 +152,7 @@ private function isVariadic(): bool
152152$ cachedResult = $ this ->cache ->load ($ key , $ variableCacheKey );
153153if ($ cachedResult === null ) {
154154$ nodes = $ this ->parser ->parseFile ($ fileName );
155- $ result = !$ this ->callsFuncGetArgs ($ nodes )->no ();
155+ $ result = !$ this ->containsVariadicFunction ($ nodes )->no ();
156156$ this ->cache ->save ($ key , $ variableCacheKey , $ result );
157157return $ result ;
158158}
@@ -167,7 +167,7 @@ private function isVariadic(): bool
167167/**
168168 * @param Node[]|scalar[]|Node $node
169169 */
170- private function callsFuncGetArgs (array |Node $ node ): TrinaryLogic
170+ private function containsVariadicFunction (array |Node $ node ): TrinaryLogic
171171{
172172$ result = TrinaryLogic::createMaybe ();
173173
@@ -176,8 +176,7 @@ private function callsFuncGetArgs(array|Node $node): TrinaryLogic
176176$ functionName = (string ) $ node ->namespacedName ;
177177
178178if ($ functionName === $ this ->reflection ->getName ()) {
179- // native variadic with ...$param is checked via ReflectionFunction->isVariadic()
180- return TrinaryLogic::createFromBoolean ($ this ->functionCallStatementFinder ->findFunctionCallInStatements (ParametersAcceptor::VARIADIC_FUNCTIONS , $ node ->getStmts ()) !== null );
179+ return TrinaryLogic::createFromBoolean ($ this ->isFunctionNodeVariadic ($ node ));
181180}
182181}
183182
@@ -187,15 +186,15 @@ private function callsFuncGetArgs(array|Node $node): TrinaryLogic
187186continue ;
188187}
189188
190- $ result = $ result ->and ($ this ->callsFuncGetArgs ($ innerNode ));
189+ $ result = $ result ->and ($ this ->containsVariadicFunction ($ innerNode ));
191190}
192191} elseif (is_array ($ node )) {
193192foreach ($ node as $ subNode ) {
194193if (!$ subNode instanceof Node) {
195194continue ;
196195}
197196
198- $ result = $ result ->and ($ this ->callsFuncGetArgs ($ subNode ));
197+ $ result = $ result ->and ($ this ->containsVariadicFunction ($ subNode ));
199198}
200199}
201200
@@ -301,4 +300,19 @@ public function acceptsNamedArguments(): bool
301300return $ this ->acceptsNamedArguments ;
302301}
303302
303+ private function isFunctionNodeVariadic (Function_ $ node ): bool
304+ {
305+ foreach ($ node ->params as $ parameter ) {
306+ if ($ parameter ->variadic ) {
307+ return true ;
308+ }
309+ }
310+
311+ if ($ this ->functionCallStatementFinder ->findFunctionCallInStatements (ParametersAcceptor::VARIADIC_FUNCTIONS , $ node ->getStmts ()) !== null ) {
312+ return true ;
313+ }
314+
315+ return false ;
316+ }
317+
304318}
0 commit comments