Skip to content

Commit

Permalink
Return null for no change
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgsowa committed Dec 19, 2024
1 parent 9f93d6d commit 54553da
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion rules/Php84/Rector/FuncCall/RoundingModeEnumRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public function refactor(Node $node): ?Node\Expr\FuncCall

$modeArg = $args[2]->value;

$hasChanged = false;
if ($modeArg instanceof ConstFetch) {
if (isset($modeArg->name->getParts()[0])) {
$enumCase = match ($modeArg->name->getParts()[0]) {
Expand All @@ -80,10 +81,15 @@ public function refactor(Node $node): ?Node\Expr\FuncCall
}

$args[2]->value = new Node\Expr\ClassConstFetch(new FullyQualified('RoundingMode'), $enumCase);
$hasChanged = true;
}
}

return $node;
if ($hasChanged) {
return $node;
}

return null;
}

public function provideMinPhpVersion(): int
Expand Down

0 comments on commit 54553da

Please sign in to comment.