diff --git a/rules-tests/Php81/Rector/Property/ReadOnlyPropertyRector/Fixture/skip_no_type.php.inc b/rules-tests/Php81/Rector/Property/ReadOnlyPropertyRector/Fixture/skip_no_type.php.inc new file mode 100644 index 00000000000..48221146bd8 --- /dev/null +++ b/rules-tests/Php81/Rector/Property/ReadOnlyPropertyRector/Fixture/skip_no_type.php.inc @@ -0,0 +1,18 @@ +name = $name; + } + + public function getName() + { + return $this->name; + } +} diff --git a/rules/Php81/Rector/Property/ReadOnlyPropertyRector.php b/rules/Php81/Rector/Property/ReadOnlyPropertyRector.php index cc496943dc1..83511a0e2cd 100644 --- a/rules/Php81/Rector/Property/ReadOnlyPropertyRector.php +++ b/rules/Php81/Rector/Property/ReadOnlyPropertyRector.php @@ -93,6 +93,10 @@ public function refactor(Node $node): ?Node return null; } + if ($node->type === null) { + return null; + } + $this->visibilityManipulator->makeReadonly($node); return $node; }