From e93bd2879eaa974cf2bc7c025b235bbac28b627b Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 30 Jun 2026 14:03:53 +0200 Subject: [PATCH] [TypeDeclaration] Skip variadic param in AddMethodCallBasedStrictParamTypeRector --- .../Fixture/skip_variadic_param.php.inc | 15 +++++++++++++++ .../ClassMethodParamTypeCompleter.php | 6 ++++++ 2 files changed, 21 insertions(+) create mode 100644 rules-tests/TypeDeclaration/Rector/ClassMethod/AddMethodCallBasedStrictParamTypeRector/Fixture/skip_variadic_param.php.inc 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; }