From d4977511748179d1a3da17a1c8d1469e993456f9 Mon Sep 17 00:00:00 2001 From: Jorg Sowa Date: Fri, 20 Dec 2024 00:02:26 +0100 Subject: [PATCH 01/13] [DowngradePhp84] Downgrade RoundingMode enum --- .../DowngradeRoundingModeEnumRectorTest.php | 28 +++++++ .../Fixture/fixture.php.inc | 37 ++++++++ .../skip_indirect_use_of_roundin_mode.php.inc | 10 +++ .../config/configured_rule.php | 10 +++ .../DowngradeRoundingModeEnumRector.php | 84 +++++++++++++++++++ 5 files changed, 169 insertions(+) create mode 100644 rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/DowngradeRoundingModeEnumRectorTest.php create mode 100644 rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/fixture.php.inc create mode 100644 rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/skip_indirect_use_of_roundin_mode.php.inc create mode 100644 rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/config/configured_rule.php create mode 100644 rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php diff --git a/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/DowngradeRoundingModeEnumRectorTest.php b/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/DowngradeRoundingModeEnumRectorTest.php new file mode 100644 index 00000000..312fbddf --- /dev/null +++ b/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/DowngradeRoundingModeEnumRectorTest.php @@ -0,0 +1,28 @@ +doTestFile($filePath); + } + + public static function provideData(): Iterator + { + return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + public function provideConfigFilePath(): string + { + return __DIR__ . '/config/configured_rule.php'; + } +} diff --git a/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/fixture.php.inc b/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/fixture.php.inc new file mode 100644 index 00000000..ad57e63e --- /dev/null +++ b/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/fixture.php.inc @@ -0,0 +1,37 @@ + +----- + diff --git a/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/skip_indirect_use_of_roundin_mode.php.inc b/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/skip_indirect_use_of_roundin_mode.php.inc new file mode 100644 index 00000000..3d095cef --- /dev/null +++ b/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/skip_indirect_use_of_roundin_mode.php.inc @@ -0,0 +1,10 @@ + diff --git a/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/config/configured_rule.php b/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/config/configured_rule.php new file mode 100644 index 00000000..27680d6a --- /dev/null +++ b/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/config/configured_rule.php @@ -0,0 +1,10 @@ +rule(DowngradeRoundingModeEnumRector::class); +}; diff --git a/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php b/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php new file mode 100644 index 00000000..f6572232 --- /dev/null +++ b/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php @@ -0,0 +1,84 @@ +isName($node, 'round')) { + return null; + } + + if ($node->isFirstClassCallable()) { + return null; + } + + $args = $node->getArgs(); + + if (count($args) !== 3) { + return null; + } + + $modeArg = $args[2]->value; + if ($modeArg instanceof ClassConstFetch) { + if ($modeArg->class->name === 'RoundingMode') { + $constantName = match ($modeArg->name->name) { + 'HalfAwayFromZero' => 'PHP_ROUND_HALF_UP', + 'HalfTowardsZero' => 'PHP_ROUND_HALF_DOWN', + 'HalfEven' => 'PHP_ROUND_HALF_EVEN', + 'HalfOdd' => 'PHP_ROUND_HALF_ODD', + default => null, + }; + + if ($constantName === null) { + return null; + } + + $args[2]->value = new Node\Expr\ConstFetch(new Node\Name($constantName)); + } + } + + return $node; + } +} From 8d1c1ca6f85c0ece0b1443094879c81a6ed83d51 Mon Sep 17 00:00:00 2001 From: Jorg Sowa Date: Fri, 20 Dec 2024 00:10:18 +0100 Subject: [PATCH 02/13] Review comments --- .../FuncCall/DowngradeRoundingModeEnumRector.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php b/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php index f6572232..46cc9231 100644 --- a/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php +++ b/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php @@ -60,7 +60,12 @@ public function refactor(Node $node): ?Node return null; } + if (!isset($args[2])) { + return null; + } + $modeArg = $args[2]->value; + $hasChanged = false; if ($modeArg instanceof ClassConstFetch) { if ($modeArg->class->name === 'RoundingMode') { $constantName = match ($modeArg->name->name) { @@ -76,9 +81,14 @@ public function refactor(Node $node): ?Node } $args[2]->value = new Node\Expr\ConstFetch(new Node\Name($constantName)); + $hasChanged = true; } } - return $node; + if ($hasChanged) { + return $node; + } + + return null; } } From c78fd720338488bc1c0aa7173ad8f901013de154 Mon Sep 17 00:00:00 2001 From: Jorg Sowa Date: Fri, 20 Dec 2024 00:11:00 +0100 Subject: [PATCH 03/13] Fixed description of rule --- .../Rector/FuncCall/DowngradeRoundingModeEnumRector.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php b/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php index 46cc9231..043bf610 100644 --- a/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php +++ b/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php @@ -12,9 +12,9 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** - * @changelog https://wiki.php.net/rfc/new_without_parentheses + * @changelog wiki.php.net/rfc/correctly_name_the_rounding_mode_and_make_it_an_enum * - * @see \Rector\Tests\DowngradePhp84\Rector\MethodCall\DowngradeNewMethodCallWithoutParenthesesRector\DowngradeNewMethodCallWithoutParenthesesRectorTest + * @see \Rector\Tests\DowngradePhp84\Rector\FuncCall\DowngradeRoundingModeEnumRector\DowngradeRoundingModeEnumRectorTest */ final class DowngradeRoundingModeEnumRector extends AbstractRector { From 978bfeecc187b94a9025394858342a48fe07c148 Mon Sep 17 00:00:00 2001 From: Jorg Sowa Date: Fri, 20 Dec 2024 00:18:22 +0100 Subject: [PATCH 04/13] Registered rule to downgrade-php84 ruleset --- config/set/downgrade-php84.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/set/downgrade-php84.php b/config/set/downgrade-php84.php index a5d80aad..d3d914cc 100644 --- a/config/set/downgrade-php84.php +++ b/config/set/downgrade-php84.php @@ -3,6 +3,7 @@ declare(strict_types=1); use Rector\Config\RectorConfig; +use Rector\DowngradePhp84\Rector\FuncCall\DowngradeRoundingModeEnumRector; use Rector\DowngradePhp84\Rector\MethodCall\DowngradeNewMethodCallWithoutParenthesesRector; use Rector\ValueObject\PhpVersion; @@ -10,5 +11,6 @@ $rectorConfig->phpVersion(PhpVersion::PHP_83); $rectorConfig->rules([ DowngradeNewMethodCallWithoutParenthesesRector::class, + DowngradeRoundingModeEnumRector::class, ]); }; From e6997523beb2e9ce7be1af5a2584c0033d8ae207 Mon Sep 17 00:00:00 2001 From: Jorg Sowa Date: Fri, 20 Dec 2024 00:25:36 +0100 Subject: [PATCH 05/13] Used FullyQualified for constant name --- .../Fixture/fixture.php.inc | 8 ++++---- .../Rector/FuncCall/DowngradeRoundingModeEnumRector.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/fixture.php.inc b/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/fixture.php.inc index ad57e63e..7aa68729 100644 --- a/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/fixture.php.inc +++ b/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/fixture.php.inc @@ -23,10 +23,10 @@ namespace Rector\Tests\Php84\Rector\FuncCall\RoundingModeEnumRector; round(1.5, 0); round(1.5); -round(1.5, 0, PHP_ROUND_HALF_UP); -round(1.5, 0, PHP_ROUND_HALF_DOWN); -round(1.5, 0, PHP_ROUND_HALF_EVEN); -round(1.5, 0, PHP_ROUND_HALF_ODD); +round(1.5, 0, \PHP_ROUND_HALF_UP); +round(1.5, 0, \PHP_ROUND_HALF_DOWN); +round(1.5, 0, \PHP_ROUND_HALF_EVEN); +round(1.5, 0, \PHP_ROUND_HALF_ODD); round(1.5, 0, \RoundingMode::TowardsZero); round(1.5, 0, \RoundingMode::AwayFromZero); round(1.5, 0, \RoundingMode::NegativeInfinity); diff --git a/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php b/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php index 043bf610..39524285 100644 --- a/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php +++ b/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php @@ -80,7 +80,7 @@ public function refactor(Node $node): ?Node return null; } - $args[2]->value = new Node\Expr\ConstFetch(new Node\Name($constantName)); + $args[2]->value = new Node\Expr\ConstFetch(new Node\Name\FullyQualified($constantName)); $hasChanged = true; } } From 26ea27cd29cb1f655beb99901090b599ff82fec6 Mon Sep 17 00:00:00 2001 From: Jorg Sowa Date: Fri, 20 Dec 2024 00:36:47 +0100 Subject: [PATCH 06/13] Fixed PHPStan issue --- .../FuncCall/DowngradeRoundingModeEnumRector.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php b/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php index 39524285..260f514f 100644 --- a/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php +++ b/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php @@ -7,6 +7,7 @@ use PhpParser\Node; use PhpParser\Node\Expr\ClassConstFetch; use PhpParser\Node\Expr\MethodCall; +use PhpParser\Node\Name; use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -46,7 +47,7 @@ public function getRuleDefinition(): RuleDefinition */ public function refactor(Node $node): ?Node { - if (!$this->isName($node, 'round')) { + if (! $this->isName($node, 'round')) { return null; } @@ -60,14 +61,17 @@ public function refactor(Node $node): ?Node return null; } - if (!isset($args[2])) { + if (! isset($args[2])) { return null; } $modeArg = $args[2]->value; $hasChanged = false; if ($modeArg instanceof ClassConstFetch) { - if ($modeArg->class->name === 'RoundingMode') { + if ($modeArg->class instanceof Name && $modeArg->class->name === 'RoundingMode') { + if (!($modeArg->name instanceof Node\Identifier)) { + return null; + } $constantName = match ($modeArg->name->name) { 'HalfAwayFromZero' => 'PHP_ROUND_HALF_UP', 'HalfTowardsZero' => 'PHP_ROUND_HALF_DOWN', From 8285cfbfa782f0bb6870b01ef17557e85ce06e79 Mon Sep 17 00:00:00 2001 From: Jorg Sowa Date: Fri, 20 Dec 2024 00:48:18 +0100 Subject: [PATCH 07/13] Formatting --- .../DowngradeRoundingModeEnumRector.php | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php b/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php index 260f514f..82465de4 100644 --- a/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php +++ b/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php @@ -6,8 +6,12 @@ use PhpParser\Node; use PhpParser\Node\Expr\ClassConstFetch; +use PhpParser\Node\Expr\ConstFetch; +use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\MethodCall; +use PhpParser\Node\Identifier; use PhpParser\Node\Name; +use PhpParser\Node\Name\FullyQualified; use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -21,7 +25,7 @@ final class DowngradeRoundingModeEnumRector extends AbstractRector { public function getNodeTypes(): array { - return [Node\Expr\FuncCall::class]; + return [FuncCall::class]; } public function getRuleDefinition(): RuleDefinition @@ -67,26 +71,23 @@ public function refactor(Node $node): ?Node $modeArg = $args[2]->value; $hasChanged = false; - if ($modeArg instanceof ClassConstFetch) { - if ($modeArg->class instanceof Name && $modeArg->class->name === 'RoundingMode') { - if (!($modeArg->name instanceof Node\Identifier)) { - return null; - } - $constantName = match ($modeArg->name->name) { - 'HalfAwayFromZero' => 'PHP_ROUND_HALF_UP', - 'HalfTowardsZero' => 'PHP_ROUND_HALF_DOWN', - 'HalfEven' => 'PHP_ROUND_HALF_EVEN', - 'HalfOdd' => 'PHP_ROUND_HALF_ODD', - default => null, - }; - - if ($constantName === null) { - return null; - } + if ($modeArg instanceof ClassConstFetch && ($modeArg->class instanceof Name && $modeArg->class->name === 'RoundingMode')) { + if (! ($modeArg->name instanceof Identifier)) { + return null; + } - $args[2]->value = new Node\Expr\ConstFetch(new Node\Name\FullyQualified($constantName)); - $hasChanged = true; + $constantName = match ($modeArg->name->name) { + 'HalfAwayFromZero' => 'PHP_ROUND_HALF_UP', + 'HalfTowardsZero' => 'PHP_ROUND_HALF_DOWN', + 'HalfEven' => 'PHP_ROUND_HALF_EVEN', + 'HalfOdd' => 'PHP_ROUND_HALF_ODD', + default => null, + }; + if ($constantName === null) { + return null; } + $args[2]->value = new ConstFetch(new FullyQualified($constantName)); + $hasChanged = true; } if ($hasChanged) { From 97394aa318f3c92567caeb99ae556a5b8f5744da Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 20 Dec 2024 06:55:49 +0700 Subject: [PATCH 08/13] run rector once more --- .../Rector/FuncCall/DowngradeRoundingModeEnumRector.php | 1 + 1 file changed, 1 insertion(+) diff --git a/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php b/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php index 82465de4..0bca4d20 100644 --- a/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php +++ b/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php @@ -86,6 +86,7 @@ public function refactor(Node $node): ?Node if ($constantName === null) { return null; } + $args[2]->value = new ConstFetch(new FullyQualified($constantName)); $hasChanged = true; } From 46767bf6dea73753343bd1377f403f28c55542b0 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 20 Dec 2024 06:58:11 +0700 Subject: [PATCH 09/13] ensure FullyQualified check --- .../Rector/FuncCall/DowngradeRoundingModeEnumRector.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php b/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php index 0bca4d20..3d0a1b01 100644 --- a/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php +++ b/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php @@ -71,8 +71,8 @@ public function refactor(Node $node): ?Node $modeArg = $args[2]->value; $hasChanged = false; - if ($modeArg instanceof ClassConstFetch && ($modeArg->class instanceof Name && $modeArg->class->name === 'RoundingMode')) { - if (! ($modeArg->name instanceof Identifier)) { + if ($modeArg instanceof ClassConstFetch && $modeArg->class instanceof FullyQualified && $this->isName($modeArg->class, 'RoundingMode')) { + if (! $modeArg->name instanceof Identifier) { return null; } From b27b29d44d94c7cd61e190f53c94ee2b7ab43134 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 20 Dec 2024 07:01:11 +0700 Subject: [PATCH 10/13] add no namespace fixture --- .../Fixture/fixture.php.inc | 28 +------------- .../Fixture/no_namespace.php.inc | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+), 27 deletions(-) create mode 100644 rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/no_namespace.php.inc diff --git a/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/fixture.php.inc b/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/fixture.php.inc index 7aa68729..47d17f3b 100644 --- a/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/fixture.php.inc +++ b/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/fixture.php.inc @@ -1,37 +1,11 @@ ----- diff --git a/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/no_namespace.php.inc b/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/no_namespace.php.inc new file mode 100644 index 00000000..7aa68729 --- /dev/null +++ b/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/no_namespace.php.inc @@ -0,0 +1,37 @@ + +----- + From 942d28ae01a8f0c1a2337808c48aa7b7c10a494d Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 20 Dec 2024 07:03:08 +0700 Subject: [PATCH 11/13] from use --- .../Fixture/fixture.php.inc | 28 ++++++++++++++++++- .../Fixture/from_use.php.inc | 19 +++++++++++++ .../Fixture/no_namespace.php.inc | 28 +------------------ 3 files changed, 47 insertions(+), 28 deletions(-) create mode 100644 rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/from_use.php.inc diff --git a/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/fixture.php.inc b/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/fixture.php.inc index 47d17f3b..7aa68729 100644 --- a/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/fixture.php.inc +++ b/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/fixture.php.inc @@ -1,11 +1,37 @@ ----- diff --git a/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/from_use.php.inc b/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/from_use.php.inc new file mode 100644 index 00000000..7a4178a4 --- /dev/null +++ b/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/from_use.php.inc @@ -0,0 +1,19 @@ + +----- + diff --git a/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/no_namespace.php.inc b/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/no_namespace.php.inc index 7aa68729..47d17f3b 100644 --- a/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/no_namespace.php.inc +++ b/rules-tests/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector/Fixture/no_namespace.php.inc @@ -1,37 +1,11 @@ ----- From 9bab6264c54ecec7ee4f186e53e57edc07c5e15b Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 20 Dec 2024 07:05:01 +0700 Subject: [PATCH 12/13] run rector once more --- .../Rector/FuncCall/DowngradeRoundingModeEnumRector.php | 1 - 1 file changed, 1 deletion(-) diff --git a/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php b/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php index 3d0a1b01..e39cbe83 100644 --- a/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php +++ b/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php @@ -10,7 +10,6 @@ use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Identifier; -use PhpParser\Node\Name; use PhpParser\Node\Name\FullyQualified; use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; From d2dafe6ee57e5d2fd01c204b529ffbbfd8518f1d Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 20 Dec 2024 07:06:26 +0700 Subject: [PATCH 13/13] cs fix --- .../Rector/FuncCall/DowngradeRoundingModeEnumRector.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php b/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php index e39cbe83..f6786555 100644 --- a/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php +++ b/rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php @@ -70,7 +70,10 @@ public function refactor(Node $node): ?Node $modeArg = $args[2]->value; $hasChanged = false; - if ($modeArg instanceof ClassConstFetch && $modeArg->class instanceof FullyQualified && $this->isName($modeArg->class, 'RoundingMode')) { + if ($modeArg instanceof ClassConstFetch && $modeArg->class instanceof FullyQualified && $this->isName( + $modeArg->class, + 'RoundingMode' + )) { if (! $modeArg->name instanceof Identifier) { return null; }