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 9d5e1d70a33..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 @@ -56,6 +57,7 @@ parameters: phpunit: true mocks: true ctor: true + modern: true # see https://github.com/TomasVotruba/type-coverage type_coverage: @@ -81,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 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 @@ 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; } diff --git a/tests/Issues/PrintCrash/PrintCrashTest.php b/tests/Issues/PrintCrash/PrintCrashTest.php deleted file mode 100644 index 8c6f0d25efb..00000000000 --- a/tests/Issues/PrintCrash/PrintCrashTest.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/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); -};