From 6fcabc133eaa6025b9bb7a5725bd7122282ab354 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 2 Dec 2021 11:19:05 +0700 Subject: [PATCH 1/2] [Php81] Skip no type param on ReadOnlyPropertyRector --- .../Fixture/skip_no_type_param.php.inc | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 rules-tests/Php81/Rector/Property/ReadOnlyPropertyRector/Fixture/skip_no_type_param.php.inc diff --git a/rules-tests/Php81/Rector/Property/ReadOnlyPropertyRector/Fixture/skip_no_type_param.php.inc b/rules-tests/Php81/Rector/Property/ReadOnlyPropertyRector/Fixture/skip_no_type_param.php.inc new file mode 100644 index 00000000000..80a8a2aed64 --- /dev/null +++ b/rules-tests/Php81/Rector/Property/ReadOnlyPropertyRector/Fixture/skip_no_type_param.php.inc @@ -0,0 +1,22 @@ +data; + } +} \ No newline at end of file From 42f5efee8b182065c2fa52d809c89c53cf49fed3 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 2 Dec 2021 11:20:34 +0700 Subject: [PATCH 2/2] fix --- .../ReadOnlyPropertyRector/Fixture/skip_no_type_param.php.inc | 2 +- rules/Php81/Rector/Property/ReadOnlyPropertyRector.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/rules-tests/Php81/Rector/Property/ReadOnlyPropertyRector/Fixture/skip_no_type_param.php.inc b/rules-tests/Php81/Rector/Property/ReadOnlyPropertyRector/Fixture/skip_no_type_param.php.inc index 80a8a2aed64..5d86889899d 100644 --- a/rules-tests/Php81/Rector/Property/ReadOnlyPropertyRector/Fixture/skip_no_type_param.php.inc +++ b/rules-tests/Php81/Rector/Property/ReadOnlyPropertyRector/Fixture/skip_no_type_param.php.inc @@ -19,4 +19,4 @@ final class SkipNoTypeParam { return $this->data; } -} \ No newline at end of file +} diff --git a/rules/Php81/Rector/Property/ReadOnlyPropertyRector.php b/rules/Php81/Rector/Property/ReadOnlyPropertyRector.php index 2e3004d3488..f69cbc5b5d9 100644 --- a/rules/Php81/Rector/Property/ReadOnlyPropertyRector.php +++ b/rules/Php81/Rector/Property/ReadOnlyPropertyRector.php @@ -116,6 +116,10 @@ private function refactorParam(Param $param): Param | null return null; } + if ($param->type === null) { + return null; + } + // promoted property? if ($this->propertyManipulator->isPropertyChangeableExceptConstructor($param)) { return null;