From d8c9458918ce7eb77afac39373ae8e0209bbf8cd Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 31 Jul 2026 18:58:51 +0200 Subject: [PATCH] [depre] Remove 4 rules deprecated since 2025-10 CreateMockToAnonymousClassRector, AddParentSetupCallOnSetupRector, SetUpBeforeClassToSetUpRector and RemoveDataProviderParamKeysRector have been throwing on refactor() for 9 months. None of them is part of a set and none has tests left. --- .../CreateMockToAnonymousClassRector.php | 78 ---------------- .../AddParentSetupCallOnSetupRector.php | 71 --------------- .../RemoveDataProviderParamKeysRector.php | 88 ------------------- .../Class_/SetUpBeforeClassToSetUpRector.php | 84 ------------------ 4 files changed, 321 deletions(-) delete mode 100644 rules/CodeQuality/Rector/ClassMethod/CreateMockToAnonymousClassRector.php delete mode 100644 rules/CodeQuality/Rector/Class_/AddParentSetupCallOnSetupRector.php delete mode 100644 rules/CodeQuality/Rector/Class_/RemoveDataProviderParamKeysRector.php delete mode 100644 rules/CodeQuality/Rector/Class_/SetUpBeforeClassToSetUpRector.php diff --git a/rules/CodeQuality/Rector/ClassMethod/CreateMockToAnonymousClassRector.php b/rules/CodeQuality/Rector/ClassMethod/CreateMockToAnonymousClassRector.php deleted file mode 100644 index 6bb13e90..00000000 --- a/rules/CodeQuality/Rector/ClassMethod/CreateMockToAnonymousClassRector.php +++ /dev/null @@ -1,78 +0,0 @@ -createMock() with methods to direct anonymous class', [ - new CodeSample( - <<<'CODE_SAMPLE' -use PHPUnit\Framework\TestCase; - -final class SomeTest extends TestCase -{ - public function test() - { - $someMockObject = $this->createMock(SomeClass::class); - - $someMockObject->method('someMethod') - ->willReturn(100); - } -} -CODE_SAMPLE - - , - <<<'CODE_SAMPLE' -use PHPUnit\Framework\TestCase; - -final class SomeTest extends TestCase -{ - public function test() - { - $someMockObject = new class extends SomeClass { - public function someMethod() - { - return 100; - } - }; - } -} -CODE_SAMPLE - ), - ]); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [ClassMethod::class]; - } - - /** - * @param ClassMethod $node - */ - public function refactor(Node $node): ?Node - { - throw new ShouldNotHappenException(sprintf( - '"%s" rule is deprecated, as works only sometimes. It requires manual check, as value object can be better solution.', - self::class - )); - } -} diff --git a/rules/CodeQuality/Rector/Class_/AddParentSetupCallOnSetupRector.php b/rules/CodeQuality/Rector/Class_/AddParentSetupCallOnSetupRector.php deleted file mode 100644 index 7f99b5b0..00000000 --- a/rules/CodeQuality/Rector/Class_/AddParentSetupCallOnSetupRector.php +++ /dev/null @@ -1,71 +0,0 @@ -> - */ - public function getNodeTypes(): array - { - return [Class_::class]; - } - - /** - * @param Class_ $node - */ - public function refactor(Node $node): ?Node - { - throw new ShouldNotHappenException( - sprintf('Rule "%s" is deprecated. Better add parent::setUp() manually where needed.', self::class) - ); - } -} diff --git a/rules/CodeQuality/Rector/Class_/RemoveDataProviderParamKeysRector.php b/rules/CodeQuality/Rector/Class_/RemoveDataProviderParamKeysRector.php deleted file mode 100644 index 2ea0672c..00000000 --- a/rules/CodeQuality/Rector/Class_/RemoveDataProviderParamKeysRector.php +++ /dev/null @@ -1,88 +0,0 @@ - ['Tom'], - ]; - } -} -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -use PHPUnit\Framework\TestCase; -use PHPUnit\Framework\DataProvider; - -final class SomeServiceTest extends TestCase -{ - #[DataProvider('provideData')] - public function test(string $name): void - { - } - - public function provideData(): array - { - return [ - ['Tom'], - ]; - } -} -CODE_SAMPLE - , - ), - ]); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [Class_::class]; - } - - /** - * @param Class_ $node - */ - public function refactor(Node $node): ?Node - { - throw new ShouldNotHappenException(sprintf( - '"%s" is deprecated and should not be used anymore. Remove it from your config files.', - self::class, - )); - } -} diff --git a/rules/CodeQuality/Rector/Class_/SetUpBeforeClassToSetUpRector.php b/rules/CodeQuality/Rector/Class_/SetUpBeforeClassToSetUpRector.php deleted file mode 100644 index 68e8fd26..00000000 --- a/rules/CodeQuality/Rector/Class_/SetUpBeforeClassToSetUpRector.php +++ /dev/null @@ -1,84 +0,0 @@ -getValue(); - } -} -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -use PHPUnit\Framework\TestCase; - -final class SomeTest extends TestCase -{ - private $someService; - - protected function setUp(): void - { - $this->someService = new SomeService(); - } - - public function test() - { - $result = $this->someService->getValue(); - } -} -CODE_SAMPLE - , - ), - ]); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [Class_::class]; - } - - /** - * @param Class_ $node - */ - public function refactor(Node $node): ?Node - { - throw new ShouldNotHappenException(sprintf( - '"%s" is deprecated and should not be used anymore. Remove it from your config files.', - self::class, - )); - } -}