From cec23b37b290fe57931fa426b690549c30130cbe Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 2 Dec 2021 14:19:26 +0700 Subject: [PATCH] [Php81] Skip no type param on ReadOnlyPropertyRector (#1365) * [Php81] Skip no type param on ReadOnlyPropertyRector * fix --- .../Fixture/skip_no_type_param.php.inc | 22 +++++++++++++++++++ .../Property/ReadOnlyPropertyRector.php | 4 ++++ 2 files changed, 26 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..5d86889899d --- /dev/null +++ b/rules-tests/Php81/Rector/Property/ReadOnlyPropertyRector/Fixture/skip_no_type_param.php.inc @@ -0,0 +1,22 @@ +data; + } +} 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;