From 00295fa51bab5b843a565cc2136c0b55d7951ed1 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 16 Oct 2026 11:27:33 +0200 Subject: [PATCH 1/3] cs --- phpstan.neon | 1 + .../Rector/ClassMethod/AddParamTypeDeclarationRector.php | 2 +- .../Rector/Class_/ChildDoctrineRepositoryClassTypeRector.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 9d5e1d70a33..98936795aea 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -56,6 +56,7 @@ parameters: phpunit: true mocks: true ctor: true + modern: true # see https://github.com/TomasVotruba/type-coverage type_coverage: diff --git a/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeDeclarationRector.php b/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeDeclarationRector.php index 745851e56dc..c7f08102e6b 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeDeclarationRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeDeclarationRector.php @@ -88,7 +88,7 @@ public function refactor(Node $node): ?Node $this->hasChanged = false; // skip class without parents/interfaces, there is no param type to mimic - if ($node instanceof Class_ && !$node->extends instanceof Name && $node->implements === []) { + if ($node instanceof Class_ && ! $node->extends instanceof Name && $node->implements === []) { return null; } diff --git a/rules/TypeDeclaration/Rector/Class_/ChildDoctrineRepositoryClassTypeRector.php b/rules/TypeDeclaration/Rector/Class_/ChildDoctrineRepositoryClassTypeRector.php index a34f09a8f17..5236c56faec 100644 --- a/rules/TypeDeclaration/Rector/Class_/ChildDoctrineRepositoryClassTypeRector.php +++ b/rules/TypeDeclaration/Rector/Class_/ChildDoctrineRepositoryClassTypeRector.php @@ -96,7 +96,7 @@ public function getNodeTypes(): array public function refactor(Node $node): ?Node { // entity type is resolved from the @extends docblock, bail early when absent - if (!$node->getDocComment() instanceof Doc) { + if (! $node->getDocComment() instanceof Doc) { return null; } From 66a7eaa52984a080d14ac439a467cc5f0f94a6c9 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 16 Oct 2026 11:29:07 +0200 Subject: [PATCH 2/3] decouple deprecated phpstan ignores to phpstan-deprecated.neon --- phpstan-deprecated.neon | 35 +++++++++++++++++++++++++++++++++++ phpstan.neon | 34 +--------------------------------- 2 files changed, 36 insertions(+), 33 deletions(-) create mode 100644 phpstan-deprecated.neon diff --git a/phpstan-deprecated.neon b/phpstan-deprecated.neon new file mode 100644 index 00000000000..544d8441d5f --- /dev/null +++ b/phpstan-deprecated.neon @@ -0,0 +1,35 @@ +# deprecated code kept temporarily, ignores to drop once the deprecated API is removed +parameters: + ignoreErrors: + # deprecated, to be removed + - + message: '#^Unused Rector\\Set\\Contract\\SetInterface\:\:(.*?)$#' + identifier: shipmonk.deadMethod + path: src/Set/Contract/SetInterface.php + + # the deprecated set objects are still resolved internally, until every extension bonds its rules + - + message: '#deprecated (class|interface) Rector\\(Set|Bridge)\\#' + path: src/Configuration/RectorConfigBuilder.php + + # EARLY_RETURN set is deprecated (empty, merged into code-quality), still mapped internally until removed + - + identifier: classConstant.deprecated + paths: + - src/Configuration/RectorConfigBuilder.php + + # the deprecated SetList::PHP_* constants are still resolved internally by the level sets and their tests + - + identifier: classConstant.deprecated + paths: + - config/set/level + - tests/Bridge/SetRectorsResolverTest.php + + # the deprecated github/gitlab output formatters are still tested until removed in next minor version + - + identifier: new.deprecatedClass + path: tests/ChangesReporting/Output/GitHubOutputFormatterTest.php + + - + identifier: method.deprecatedClass + path: tests/ChangesReporting/Output/GitHubOutputFormatterTest.php diff --git a/phpstan.neon b/phpstan.neon index 98936795aea..e8b0478cc81 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,6 @@ includes: - vendor/symplify/phpstan-rules/config/rector-rules.neon + - phpstan-deprecated.neon rules: - Rector\Utils\PHPStan\Rule\RegisterRelatedPolyfillRectorRule @@ -82,39 +83,6 @@ parameters: identifier: shipmonk.deadMethod path: src/PhpParser/Printer/BetterStandardPrinter.php - # deprecated, to be removed - - - message: '#^Unused Rector\\Set\\Contract\\SetInterface\:\:(.*?)$#' - identifier: shipmonk.deadMethod - path: src/Set/Contract/SetInterface.php - - # the deprecated set objects are still resolved internally, until every extension bonds its rules - - - message: '#deprecated (class|interface) Rector\\(Set|Bridge)\\#' - path: src/Configuration/RectorConfigBuilder.php - - # EARLY_RETURN set is deprecated (empty, merged into code-quality), still mapped internally until removed - - - identifier: classConstant.deprecated - paths: - - src/Configuration/RectorConfigBuilder.php - - # the deprecated SetList::PHP_* constants are still resolved internally by the level sets and their tests - - - identifier: classConstant.deprecated - paths: - - config/set/level - - tests/Bridge/SetRectorsResolverTest.php - - # the deprecated github/gitlab output formatters are still tested until removed in next minor version - - - identifier: new.deprecatedClass - path: tests/ChangesReporting/Output/GitHubOutputFormatterTest.php - - - - identifier: method.deprecatedClass - path: tests/ChangesReporting/Output/GitHubOutputFormatterTest.php - - identifier: argument.templateType path: rules/TypeDeclaration/Rector/FunctionLike/AddClosureParamTypeForArrayReduceRector.php From ef62493041eb6f303f9ae05784312dfab74cf7f6 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 16 Oct 2026 11:46:42 +0200 Subject: [PATCH 3/3] move single-rule Issue tests into their rule test fixtures --- ...with_interpolated_string_part_used.php.inc | 3 +- .../callback_with_curly_braces.php.inc | 8 ++--- .../skip_callback_with_string_value.php.inc | 2 +- tests/Issues/PrintCrash/PrintCrashTest.php | 28 ---------------- .../PrintCrash/config/configured_rule.php | 10 ------ ...lassInCallbackFromAssertAnnotationTest.php | 28 ---------------- .../config/configured_rule.php | 12 ------- .../TestDocAnnotation/Fixture/fixture.php.inc | 33 ------------------- .../Fixture/multi_double_colon.php.inc | 33 ------------------- .../TestDocAnnotationTest.php | 28 ---------------- .../config/configured_rule.php | 13 -------- .../Fixture/keep_string_as_is.php.inc | 31 ----------------- .../TestWithAttributeTest.php | 28 ---------------- .../config/configured_rule.php | 10 ------ 14 files changed, 6 insertions(+), 261 deletions(-) rename {tests/Issues/PrintCrash => rules-tests/DeadCode/Rector/Foreach_/RemoveUnusedForeachKeyRector}/Fixture/skip_with_interpolated_string_part_used.php.inc (73%) rename {tests/Issues/RenameClassInCallbackFromAssertAnnotation => rules-tests/Renaming/Rector/Name/RenameClassRector}/Fixture/callback_with_curly_braces.php.inc (50%) rename tests/Issues/RenameClassInCallbackFromAssertAnnotation/Fixture/callback_with_string_value.php.inc => rules-tests/Renaming/Rector/Name/RenameClassRector/Fixture/skip_callback_with_string_value.php.inc (80%) delete mode 100644 tests/Issues/PrintCrash/PrintCrashTest.php delete mode 100644 tests/Issues/PrintCrash/config/configured_rule.php delete mode 100644 tests/Issues/RenameClassInCallbackFromAssertAnnotation/RenameClassInCallbackFromAssertAnnotationTest.php delete mode 100644 tests/Issues/RenameClassInCallbackFromAssertAnnotation/config/configured_rule.php delete mode 100644 tests/Issues/TestDocAnnotation/Fixture/fixture.php.inc delete mode 100644 tests/Issues/TestDocAnnotation/Fixture/multi_double_colon.php.inc delete mode 100644 tests/Issues/TestDocAnnotation/TestDocAnnotationTest.php delete mode 100644 tests/Issues/TestDocAnnotation/config/configured_rule.php delete mode 100644 tests/Issues/TestWithAttribute/Fixture/keep_string_as_is.php.inc delete mode 100644 tests/Issues/TestWithAttribute/TestWithAttributeTest.php delete mode 100644 tests/Issues/TestWithAttribute/config/configured_rule.php diff --git a/tests/Issues/PrintCrash/Fixture/skip_with_interpolated_string_part_used.php.inc b/rules-tests/DeadCode/Rector/Foreach_/RemoveUnusedForeachKeyRector/Fixture/skip_with_interpolated_string_part_used.php.inc similarity index 73% rename from tests/Issues/PrintCrash/Fixture/skip_with_interpolated_string_part_used.php.inc rename to rules-tests/DeadCode/Rector/Foreach_/RemoveUnusedForeachKeyRector/Fixture/skip_with_interpolated_string_part_used.php.inc index 3c231d88301..632aae6f1ca 100644 --- a/tests/Issues/PrintCrash/Fixture/skip_with_interpolated_string_part_used.php.inc +++ b/rules-tests/DeadCode/Rector/Foreach_/RemoveUnusedForeachKeyRector/Fixture/skip_with_interpolated_string_part_used.php.inc @@ -1,6 +1,6 @@ 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/tests/Issues/PrintCrash/config/configured_rule.php b/tests/Issues/PrintCrash/config/configured_rule.php deleted file mode 100644 index 033e63d7939..00000000000 --- a/tests/Issues/PrintCrash/config/configured_rule.php +++ /dev/null @@ -1,10 +0,0 @@ -rule(RemoveUnusedForeachKeyRector::class); -}; diff --git a/tests/Issues/RenameClassInCallbackFromAssertAnnotation/RenameClassInCallbackFromAssertAnnotationTest.php b/tests/Issues/RenameClassInCallbackFromAssertAnnotation/RenameClassInCallbackFromAssertAnnotationTest.php deleted file mode 100644 index 5276ed1801f..00000000000 --- a/tests/Issues/RenameClassInCallbackFromAssertAnnotation/RenameClassInCallbackFromAssertAnnotationTest.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/tests/Issues/RenameClassInCallbackFromAssertAnnotation/config/configured_rule.php b/tests/Issues/RenameClassInCallbackFromAssertAnnotation/config/configured_rule.php deleted file mode 100644 index 1a424d8bad9..00000000000 --- a/tests/Issues/RenameClassInCallbackFromAssertAnnotation/config/configured_rule.php +++ /dev/null @@ -1,12 +0,0 @@ -ruleWithConfiguration(RenameClassRector::class, [ - 'Some\Random\Class_' => 'Some\Other\Random\Class_', - ]); -}; diff --git a/tests/Issues/TestDocAnnotation/Fixture/fixture.php.inc b/tests/Issues/TestDocAnnotation/Fixture/fixture.php.inc deleted file mode 100644 index aa094791d2d..00000000000 --- a/tests/Issues/TestDocAnnotation/Fixture/fixture.php.inc +++ /dev/null @@ -1,33 +0,0 @@ - ------ - diff --git a/tests/Issues/TestDocAnnotation/Fixture/multi_double_colon.php.inc b/tests/Issues/TestDocAnnotation/Fixture/multi_double_colon.php.inc deleted file mode 100644 index f4fb4a70618..00000000000 --- a/tests/Issues/TestDocAnnotation/Fixture/multi_double_colon.php.inc +++ /dev/null @@ -1,33 +0,0 @@ - ------ - diff --git a/tests/Issues/TestDocAnnotation/TestDocAnnotationTest.php b/tests/Issues/TestDocAnnotation/TestDocAnnotationTest.php deleted file mode 100644 index 4aed7d1afb1..00000000000 --- a/tests/Issues/TestDocAnnotation/TestDocAnnotationTest.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/tests/Issues/TestDocAnnotation/config/configured_rule.php b/tests/Issues/TestDocAnnotation/config/configured_rule.php deleted file mode 100644 index e66ada2ce93..00000000000 --- a/tests/Issues/TestDocAnnotation/config/configured_rule.php +++ /dev/null @@ -1,13 +0,0 @@ -ruleWithConfiguration(AnnotationWithValueToAttributeRector::class, [ - new AnnotationWithValueToAttribute('testdox', 'PHPUnit\Framework\Attributes\TestDox'), - ]); -}; diff --git a/tests/Issues/TestWithAttribute/Fixture/keep_string_as_is.php.inc b/tests/Issues/TestWithAttribute/Fixture/keep_string_as_is.php.inc deleted file mode 100644 index fd238ca262a..00000000000 --- a/tests/Issues/TestWithAttribute/Fixture/keep_string_as_is.php.inc +++ /dev/null @@ -1,31 +0,0 @@ - ------ - diff --git a/tests/Issues/TestWithAttribute/TestWithAttributeTest.php b/tests/Issues/TestWithAttribute/TestWithAttributeTest.php deleted file mode 100644 index 35ad441ae75..00000000000 --- a/tests/Issues/TestWithAttribute/TestWithAttributeTest.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/tests/Issues/TestWithAttribute/config/configured_rule.php b/tests/Issues/TestWithAttribute/config/configured_rule.php deleted file mode 100644 index 4d4acca6e86..00000000000 --- a/tests/Issues/TestWithAttribute/config/configured_rule.php +++ /dev/null @@ -1,10 +0,0 @@ -rule(TestWithAnnotationToAttributeRector::class); -};