From 7ac5765ed07d75507159c84b459143b25a9e1cc5 Mon Sep 17 00:00:00 2001 From: Reinhard Westermann Date: Thu, 31 Aug 2023 10:42:51 +0200 Subject: [PATCH 1/4] skip variadic constructor param of mixed type --- ...ic_constructor_param_of_mixed_type.php.inc | 37 +++++++++++++++++++ .../AddParamTypeFromPropertyTypeRector.php | 4 +- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 rules-tests/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector/Fixture/skip_variadic_constructor_param_of_mixed_type.php.inc diff --git a/rules-tests/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector/Fixture/skip_variadic_constructor_param_of_mixed_type.php.inc b/rules-tests/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector/Fixture/skip_variadic_constructor_param_of_mixed_type.php.inc new file mode 100644 index 00000000000..78d8d6e7161 --- /dev/null +++ b/rules-tests/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector/Fixture/skip_variadic_constructor_param_of_mixed_type.php.inc @@ -0,0 +1,37 @@ +elements = $elements; + } +} + +?> +----- +elements = $elements; + } +} + +?> diff --git a/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector.php b/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector.php index 7d317b9d5e7..5e466e66bc7 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector.php @@ -93,7 +93,9 @@ public function refactor(Node $node): ?ClassMethod if ($param->type instanceof Node) { continue; } - + if ($param->variadic) { + continue; + } if (! $this->paramTypeAddGuard->isLegal($param, $node)) { continue; } From 353a75f884315ebec47e69a07e327520e2731ca5 Mon Sep 17 00:00:00 2001 From: Reinhard Westermann Date: Thu, 31 Aug 2023 12:22:26 +0200 Subject: [PATCH 2/4] [WIP] add testcase for explicit type --- ...dic_constructor_param_of_explicit_type.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 rules-tests/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector/Fixture/variadic_constructor_param_of_explicit_type.php diff --git a/rules-tests/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector/Fixture/variadic_constructor_param_of_explicit_type.php b/rules-tests/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector/Fixture/variadic_constructor_param_of_explicit_type.php new file mode 100644 index 00000000000..fd4a2ad54c3 --- /dev/null +++ b/rules-tests/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector/Fixture/variadic_constructor_param_of_explicit_type.php @@ -0,0 +1,35 @@ +dates = $dates; + } +} + +?> +----- +dates = $dates; + } +} + +?> \ No newline at end of file From 6970cc584056bd6c273253066dd4869a21ddc2c9 Mon Sep 17 00:00:00 2001 From: Reinhard Westermann Date: Thu, 31 Aug 2023 12:27:56 +0200 Subject: [PATCH 3/4] remove unneeded expectation as it is the same as input fixture --- ...ic_constructor_param_of_mixed_type.php.inc | 21 +------------------ 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/rules-tests/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector/Fixture/skip_variadic_constructor_param_of_mixed_type.php.inc b/rules-tests/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector/Fixture/skip_variadic_constructor_param_of_mixed_type.php.inc index 78d8d6e7161..bbb97da27e5 100644 --- a/rules-tests/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector/Fixture/skip_variadic_constructor_param_of_mixed_type.php.inc +++ b/rules-tests/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector/Fixture/skip_variadic_constructor_param_of_mixed_type.php.inc @@ -15,23 +15,4 @@ final class SkipVariadicConstructorParamOfMixedType } } -?> ------ -elements = $elements; - } -} - -?> +?> \ No newline at end of file From 9016bed14d306fcb31232d4cd56a0906ff7d320f Mon Sep 17 00:00:00 2001 From: Reinhard Westermann Date: Thu, 31 Aug 2023 12:28:57 +0200 Subject: [PATCH 4/4] Revert "[WIP] add testcase for explicit type" This reverts commit 353a75f884315ebec47e69a07e327520e2731ca5. Taking over type of doc block would be nice. As discussed in PR: we can't rely on docblock, so skipping is the safest. --- ...dic_constructor_param_of_explicit_type.php | 35 ------------------- 1 file changed, 35 deletions(-) delete mode 100644 rules-tests/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector/Fixture/variadic_constructor_param_of_explicit_type.php diff --git a/rules-tests/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector/Fixture/variadic_constructor_param_of_explicit_type.php b/rules-tests/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector/Fixture/variadic_constructor_param_of_explicit_type.php deleted file mode 100644 index fd4a2ad54c3..00000000000 --- a/rules-tests/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector/Fixture/variadic_constructor_param_of_explicit_type.php +++ /dev/null @@ -1,35 +0,0 @@ -dates = $dates; - } -} - -?> ------ -dates = $dates; - } -} - -?> \ No newline at end of file