diff --git a/rules-tests/Php74/Rector/Double/RealToFloatTypeCastRector/Fixture/fixture.php.inc b/rules-tests/Php74/Rector/Double/RealToFloatTypeCastRector/Fixture/fixture.php.inc deleted file mode 100644 index d11a32c423c..00000000000 --- a/rules-tests/Php74/Rector/Double/RealToFloatTypeCastRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,31 +0,0 @@ - ------ - diff --git a/rules-tests/Php74/Rector/Double/RealToFloatTypeCastRector/RealToFloatTypeCastRectorTest.php b/rules-tests/Php74/Rector/Double/RealToFloatTypeCastRector/RealToFloatTypeCastRectorTest.php deleted file mode 100644 index 84b5f43f7c2..00000000000 --- a/rules-tests/Php74/Rector/Double/RealToFloatTypeCastRector/RealToFloatTypeCastRectorTest.php +++ /dev/null @@ -1,28 +0,0 @@ -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/Php74/Rector/Double/RealToFloatTypeCastRector/config/configured_rule.php b/rules-tests/Php74/Rector/Double/RealToFloatTypeCastRector/config/configured_rule.php deleted file mode 100644 index 8d00ad76d47..00000000000 --- a/rules-tests/Php74/Rector/Double/RealToFloatTypeCastRector/config/configured_rule.php +++ /dev/null @@ -1,9 +0,0 @@ -withRules([RealToFloatTypeCastRector::class]); diff --git a/rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php b/rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php index ab7757d8607..eeed814e41e 100644 --- a/rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php +++ b/rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php @@ -137,10 +137,7 @@ private function cleanCastedExpr(Expr $expr): Expr private function hasCallLikeInAssignExpr(Expr $expr): bool { - return (bool) $this->betterNodeFinder->findFirst( - $expr, - $this->sideEffectNodeDetector->detectCallExpr(...) - ); + return (bool) $this->betterNodeFinder->findFirst($expr, $this->sideEffectNodeDetector->detectCallExpr(...)); } /** diff --git a/rules/DeadCode/SideEffect/SideEffectNodeDetector.php b/rules/DeadCode/SideEffect/SideEffectNodeDetector.php index 463c2464a70..40529e5ec00 100644 --- a/rules/DeadCode/SideEffect/SideEffectNodeDetector.php +++ b/rules/DeadCode/SideEffect/SideEffectNodeDetector.php @@ -48,10 +48,7 @@ public function detect(Expr $expr): bool return true; } - return (bool) $this->betterNodeFinder->findFirst( - $expr, - $this->detectCallExpr(...) - ); + return (bool) $this->betterNodeFinder->findFirst($expr, $this->detectCallExpr(...)); } public function detectCallExpr(Node $node): bool diff --git a/rules/Php74/Rector/Double/RealToFloatTypeCastRector.php b/rules/Php74/Rector/Double/RealToFloatTypeCastRector.php index 06b5f8ce45f..f4ded2b9d84 100644 --- a/rules/Php74/Rector/Double/RealToFloatTypeCastRector.php +++ b/rules/Php74/Rector/Double/RealToFloatTypeCastRector.php @@ -4,9 +4,11 @@ namespace Rector\Php74\Rector\Double; +use Rector\Renaming\Rector\Cast\RenameCastRector; use PhpParser\Node; use PhpParser\Node\Expr\Cast\Double; -use Rector\NodeTypeResolver\Node\AttributeKey; +use Rector\Configuration\Deprecation\Contract\DeprecatedInterface; +use Rector\Exception\ShouldNotHappenException; use Rector\Rector\AbstractRector; use Rector\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; @@ -14,9 +16,9 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** - * @see \Rector\Tests\Php74\Rector\Double\RealToFloatTypeCastRector\RealToFloatTypeCastRectorTest + * @deprecated Use same but configurable `Rector\Renaming\Rector\Cast\RenameCastRector` with configuration instead */ -final class RealToFloatTypeCastRector extends AbstractRector implements MinPhpVersionInterface +final class RealToFloatTypeCastRector extends AbstractRector implements MinPhpVersionInterface, DeprecatedInterface { public function provideMinPhpVersion(): int { @@ -67,14 +69,9 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - $kind = $node->getAttribute(AttributeKey::KIND); - if ($kind !== Double::KIND_REAL) { - return null; - } - - $node->setAttribute(AttributeKey::KIND, Double::KIND_FLOAT); - $node->setAttribute(AttributeKey::ORIGINAL_NODE, null); - - return $node; + throw new ShouldNotHappenException(sprintf( + 'This rule is deprecated. Use configurable "%s" rule instead.', + RenameCastRector::class, + )); } } diff --git a/src/Util/ArrayParametersMerger.php b/src/Util/ArrayParametersMerger.php index 1abab11d1a1..ba14218111f 100644 --- a/src/Util/ArrayParametersMerger.php +++ b/src/Util/ArrayParametersMerger.php @@ -15,11 +15,7 @@ final class ArrayParametersMerger public function merge(mixed $left, mixed $right): mixed { if (is_array($left) && is_array($right)) { - return $this->mergeLeftToRightWithCallable( - $left, - $right, - $this->merge(...) - ); + return $this->mergeLeftToRightWithCallable($left, $right, $this->merge(...)); } if ($left !== null) {