diff --git a/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php b/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php index 105894e1ab3..b7c4261285f 100644 --- a/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php +++ b/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php @@ -159,6 +159,7 @@ public function refactor(Node $node): ?Node return null; } + $hasChanged = false; foreach ($promotionCandidates as $promotionCandidate) { $param = $promotionCandidate->getParam(); @@ -186,6 +187,8 @@ public function refactor(Node $node): ?Node continue; } + $hasChanged = true; + // remove property from class $propertyStmtKey = $property->getAttribute(AttributeKey::STMT_KEY); unset($node->stmts[$propertyStmtKey]); @@ -249,6 +252,10 @@ public function refactor(Node $node): ?Node }); } + if (! $hasChanged) { + return null; + } + return $node; }