From 8e683d6c29a27c5b7c79f49c9f18426c02e09d69 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 6 Aug 2023 18:35:53 +0200 Subject: [PATCH] Remove RemoveParentRector as never used, handle per migration --- .../docs/rector_rules_overview.md | 88 ++++++----------- .../Fixture/fixture.php.inc | 23 ----- .../RemoveParentRectorTest.php | 28 ------ .../Source/ParentTypeToBeRemoved.php | 10 -- .../config/configured_rule.php | 12 --- .../Rector/Class_/RemoveParentRector.php | 95 ------------------- 6 files changed, 27 insertions(+), 229 deletions(-) delete mode 100644 rules-tests/Removing/Rector/Class_/RemoveParentRector/Fixture/fixture.php.inc delete mode 100644 rules-tests/Removing/Rector/Class_/RemoveParentRector/RemoveParentRectorTest.php delete mode 100644 rules-tests/Removing/Rector/Class_/RemoveParentRector/Source/ParentTypeToBeRemoved.php delete mode 100644 rules-tests/Removing/Rector/Class_/RemoveParentRector/config/configured_rule.php delete mode 100644 rules/Removing/Rector/Class_/RemoveParentRector.php diff --git a/build/target-repository/docs/rector_rules_overview.md b/build/target-repository/docs/rector_rules_overview.md index 4f04236e749..d6a60b7ebd9 100644 --- a/build/target-repository/docs/rector_rules_overview.md +++ b/build/target-repository/docs/rector_rules_overview.md @@ -1,4 +1,4 @@ -# 361 Rules Overview +# 360 Rules Overview
@@ -6,7 +6,7 @@ - [Arguments](#arguments) (6) -- [CodeQuality](#codequality) (71) +- [CodeQuality](#codequality) (70) - [CodingStyle](#codingstyle) (30) @@ -46,7 +46,7 @@ - [Privatization](#privatization) (4) -- [Removing](#removing) (6) +- [Removing](#removing) (5) - [Renaming](#renaming) (10) @@ -54,7 +54,7 @@ - [Transform](#transform) (22) -- [TypeDeclaration](#typedeclaration) (43) +- [TypeDeclaration](#typedeclaration) (44) - [Visibility](#visibility) (3) @@ -1072,29 +1072,6 @@ Replace the Double not operator (!!) by type-casting to boolean
-### ReturnTypeFromStrictScalarReturnExprRector - -Change return type based on strict scalar returns - string, int, float or bool - -- class: [`Rector\CodeQuality\Rector\ClassMethod\ReturnTypeFromStrictScalarReturnExprRector`](../rules/CodeQuality/Rector/ClassMethod/ReturnTypeFromStrictScalarReturnExprRector.php) - -```diff - final class SomeClass - { -- public function run($value) -+ public function run($value): string - { - if ($value) { - return 'yes'; - } - - return 'no'; - } - } -``` - -
- ### SetTypeToCastRector Changes `settype()` to (type) where possible @@ -5841,40 +5818,6 @@ return static function (RectorConfig $rectorConfig): void {
-### RemoveParentRector - -Removes extends class by name - -:wrench: **configure it!** - -- class: [`Rector\Removing\Rector\Class_\RemoveParentRector`](../rules/Removing/Rector/Class_/RemoveParentRector.php) - -```php -ruleWithConfiguration(RemoveParentRector::class, [ - 'SomeParentClass', - ]); -}; -``` - -↓ - -```diff --final class SomeClass extends SomeParentClass -+final class SomeClass - { - } -``` - -
- ### RemoveTraitUseRector Remove specific traits from code @@ -8064,6 +8007,29 @@ Add return type based on strict parameter type
+### ReturnTypeFromStrictScalarReturnExprRector + +Change return type based on strict scalar returns - string, int, float or bool + +- class: [`Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictScalarReturnExprRector`](../rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictScalarReturnExprRector.php) + +```diff + final class SomeClass + { +- public function run($value) ++ public function run($value): string + { + if ($value) { + return 'yes'; + } + + return 'no'; + } + } +``` + +
+ ### ReturnTypeFromStrictTernaryRector Add method return type based on strict ternary values diff --git a/rules-tests/Removing/Rector/Class_/RemoveParentRector/Fixture/fixture.php.inc b/rules-tests/Removing/Rector/Class_/RemoveParentRector/Fixture/fixture.php.inc deleted file mode 100644 index 15f4186bc0f..00000000000 --- a/rules-tests/Removing/Rector/Class_/RemoveParentRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,23 +0,0 @@ - ------ - diff --git a/rules-tests/Removing/Rector/Class_/RemoveParentRector/RemoveParentRectorTest.php b/rules-tests/Removing/Rector/Class_/RemoveParentRector/RemoveParentRectorTest.php deleted file mode 100644 index fd81ab17404..00000000000 --- a/rules-tests/Removing/Rector/Class_/RemoveParentRector/RemoveParentRectorTest.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/Removing/Rector/Class_/RemoveParentRector/Source/ParentTypeToBeRemoved.php b/rules-tests/Removing/Rector/Class_/RemoveParentRector/Source/ParentTypeToBeRemoved.php deleted file mode 100644 index fb6f541b8b7..00000000000 --- a/rules-tests/Removing/Rector/Class_/RemoveParentRector/Source/ParentTypeToBeRemoved.php +++ /dev/null @@ -1,10 +0,0 @@ -ruleWithConfiguration(RemoveParentRector::class, [ParentTypeToBeRemoved::class]); -}; diff --git a/rules/Removing/Rector/Class_/RemoveParentRector.php b/rules/Removing/Rector/Class_/RemoveParentRector.php deleted file mode 100644 index d5c7fa9bb0b..00000000000 --- a/rules/Removing/Rector/Class_/RemoveParentRector.php +++ /dev/null @@ -1,95 +0,0 @@ -> - */ - public function getNodeTypes(): array - { - return [Class_::class]; - } - - /** - * @param Class_ $node - */ - public function refactorWithScope(Node $node, Scope $scope): ?Node - { - $parentClassReflection = $this->parentClassScopeResolver->resolveParentClassReflection($scope); - if (! $parentClassReflection instanceof ClassReflection) { - return null; - } - - foreach ($this->parentClassesToRemove as $parentClassToRemove) { - if ($parentClassReflection->getName() !== $parentClassToRemove) { - continue; - } - - // remove parent class - $node->extends = null; - - return $node; - } - - return null; - } - - /** - * @param mixed[] $configuration - */ - public function configure(array $configuration): void - { - Assert::allString($configuration); - - $this->parentClassesToRemove = $configuration; - } -}