From c81a38afe7801ec7fed63ee811fdb55375f8c664 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sat, 24 Oct 2026 00:57:18 +0200 Subject: [PATCH] Return node when node mutated in place, so change is recorded --- .../DowngradeTrailingCommasInParamUseRector.php | 12 +++++++++--- .../DowngradeArbitraryExpressionsSupportRector.php | 6 +++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/rules/DowngradePhp80/Rector/ClassMethod/DowngradeTrailingCommasInParamUseRector.php b/rules/DowngradePhp80/Rector/ClassMethod/DowngradeTrailingCommasInParamUseRector.php index dfdce36b..8602a72b 100644 --- a/rules/DowngradePhp80/Rector/ClassMethod/DowngradeTrailingCommasInParamUseRector.php +++ b/rules/DowngradePhp80/Rector/ClassMethod/DowngradeTrailingCommasInParamUseRector.php @@ -86,11 +86,17 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if ($node instanceof Closure) { - $this->processUses($node); + $hasChanged = false; + + if ($node instanceof Closure && $this->processUses($node) instanceof Node) { + $hasChanged = true; + } + + if ($this->processParams($node) instanceof Node) { + $hasChanged = true; } - return $this->processParams($node); + return $hasChanged ? $node : null; } private function processUses(Closure $node): ?Node diff --git a/rules/DowngradePhp80/Rector/New_/DowngradeArbitraryExpressionsSupportRector.php b/rules/DowngradePhp80/Rector/New_/DowngradeArbitraryExpressionsSupportRector.php index bd532d78..03d259d6 100644 --- a/rules/DowngradePhp80/Rector/New_/DowngradeArbitraryExpressionsSupportRector.php +++ b/rules/DowngradePhp80/Rector/New_/DowngradeArbitraryExpressionsSupportRector.php @@ -128,6 +128,8 @@ private function isBetweenParentheses(Node $node): bool */ private function refactorAssign(array $assigns, Expression $expression): array|null { + $hasChanged = false; + foreach ($assigns as $assign) { if (! $assign->expr instanceof New_ && ! $assign->expr instanceof Instanceof_) { continue; @@ -145,6 +147,7 @@ private function refactorAssign(array $assigns, Expression $expression): array|n // mandatory to remove parentheses $newOrInstanceof->setAttribute(AttributeKey::ORIGINAL_NODE, null); + $hasChanged = true; if ($isAllowed) { continue; @@ -164,7 +167,8 @@ private function refactorAssign(array $assigns, Expression $expression): array|n return [new Expression($exprAssign), $expression]; } - return null; + // parentheses were removed in place, report the change so it gets printed + return $hasChanged ? [$expression] : null; } /**