diff --git a/rules-tests/TypeDeclaration/Rector/ClassMethod/AddMethodCallBasedStrictParamTypeRector/Fixture/skip_variadic_param.php.inc b/rules-tests/TypeDeclaration/Rector/ClassMethod/AddMethodCallBasedStrictParamTypeRector/Fixture/skip_variadic_param.php.inc new file mode 100644 index 00000000000..ba82813fc83 --- /dev/null +++ b/rules-tests/TypeDeclaration/Rector/ClassMethod/AddMethodCallBasedStrictParamTypeRector/Fixture/skip_variadic_param.php.inc @@ -0,0 +1,15 @@ +createQueryBuilder('first', 'second'); + } + + private function createQueryBuilder(...$returnValues): void + { + } +} diff --git a/rules/TypeDeclaration/NodeAnalyzer/ClassMethodParamTypeCompleter.php b/rules/TypeDeclaration/NodeAnalyzer/ClassMethodParamTypeCompleter.php index 16092575b30..104ac4f9695 100644 --- a/rules/TypeDeclaration/NodeAnalyzer/ClassMethodParamTypeCompleter.php +++ b/rules/TypeDeclaration/NodeAnalyzer/ClassMethodParamTypeCompleter.php @@ -94,6 +94,12 @@ private function shouldSkipArgumentStaticType( } $parameter = $classMethod->params[$position]; + + // skip variadic param, as resolved type belongs to single element, not the whole array + if ($parameter->variadic) { + return true; + } + if ($parameter->type === null) { return false; }