From 4e1a0915735a3640c3719049a829d1e7aff85b8a Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Thu, 8 Oct 2026 18:57:03 +0200 Subject: [PATCH] [Reporting] Remove deprecated beforeTraverse method reporter --- phpstan.neon | 1 - src/Console/Command/ProcessCommand.php | 1 - src/Console/Command/ValidateConfigCommand.php | 1 - src/Reporting/DeprecatedRulesReporter.php | 32 +------------------ .../Command/ValidateConfigCommandTest.php | 2 +- 5 files changed, 2 insertions(+), 35 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index bb045ef24d6..818693e2edd 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -325,7 +325,6 @@ parameters: - src/Configuration/RectorConfigBuilder.php - src/Validation/RectorConfigValidator.php - src/Testing/PHPUnit/AbstractLazyTestCase.php - - src/Reporting/DeprecatedRulesReporter.php - src/Configuration/OnlyRuleResolver.php # debug and internal functions diff --git a/src/Console/Command/ProcessCommand.php b/src/Console/Command/ProcessCommand.php index d9d7ef05806..be4efbd8f58 100644 --- a/src/Console/Command/ProcessCommand.php +++ b/src/Console/Command/ProcessCommand.php @@ -195,7 +195,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int // 4. Deprecations reporter $this->deprecatedRulesReporter->reportDeprecatedRules(); $this->deprecatedRulesReporter->reportDeprecatedSkippedRules(); - $this->deprecatedRulesReporter->reportDeprecatedRectorUnsupportedMethods(); $this->deprecatedRulesReporter->reportDeprecatedCacheMetaExtensions(); $this->deprecatedRulesReporter->reportDeprecatedPhpSetsMethods(); $this->deprecatedRulesReporter->reportDeprecatedAttributesSetsArgs(); diff --git a/src/Console/Command/ValidateConfigCommand.php b/src/Console/Command/ValidateConfigCommand.php index 7e193f92ae0..61bcee9af64 100644 --- a/src/Console/Command/ValidateConfigCommand.php +++ b/src/Console/Command/ValidateConfigCommand.php @@ -63,7 +63,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $issueCount += $this->deprecatedRulesReporter->reportDeprecatedPhpSetsMethods(); $issueCount += $this->deprecatedRulesReporter->reportDeprecatedAttributesSetsArgs(); $issueCount += $this->deprecatedRulesReporter->reportDeprecatedComposerBasedArgs(); - $issueCount += $this->deprecatedRulesReporter->reportDeprecatedRectorUnsupportedMethods(); $issueCount += $this->missConfigurationReporter->reportSkippedNeverRegisteredRules(); $issueCount += $this->missConfigurationReporter->reportSkippedNonRectorClasses(); diff --git a/src/Reporting/DeprecatedRulesReporter.php b/src/Reporting/DeprecatedRulesReporter.php index b0c579a77b2..36d64aee3b0 100644 --- a/src/Reporting/DeprecatedRulesReporter.php +++ b/src/Reporting/DeprecatedRulesReporter.php @@ -7,19 +7,12 @@ use Rector\Configuration\Deprecation\Contract\DeprecatedInterface; use Rector\Configuration\Option; use Rector\Configuration\Parameter\SimpleParameterProvider; -use Rector\Contract\Rector\RectorInterface; -use Rector\PhpParser\Node\FileNode; -use ReflectionMethod; use Symfony\Component\Console\Style\SymfonyStyle; final readonly class DeprecatedRulesReporter { - /** - * @param RectorInterface[] $rectors - */ public function __construct( - private SymfonyStyle $symfonyStyle, - private array $rectors + private SymfonyStyle $symfonyStyle ) { } @@ -137,27 +130,4 @@ public function reportDeprecatedComposerBasedArgs(): int return $reportedCount; } - - public function reportDeprecatedRectorUnsupportedMethods(): int - { - // to be added in related PR - if (! class_exists(FileNode::class)) { - return 0; - } - - $reportedCount = 0; - foreach ($this->rectors as $rector) { - $beforeTraverseMethodReflection = new ReflectionMethod($rector, 'beforeTraverse'); - if ($beforeTraverseMethodReflection->getDeclaringClass()->getName() === $rector::class) { - $this->symfonyStyle->warning(sprintf( - 'Rector rule "%s" uses deprecated "beforeTraverse" method. It should not be used, as will be marked as final. Not part of RectorInterface contract. Use "%s" to hook into file-level changes instead.', - $rector::class, - FileNode::class - )); - ++$reportedCount; - } - } - - return $reportedCount; - } } diff --git a/tests/Console/Command/ValidateConfigCommandTest.php b/tests/Console/Command/ValidateConfigCommandTest.php index ffb33346211..115ec0e432d 100644 --- a/tests/Console/Command/ValidateConfigCommandTest.php +++ b/tests/Console/Command/ValidateConfigCommandTest.php @@ -50,7 +50,7 @@ protected function setUp(): void $validateConfigCommand = new ValidateConfigCommand( $symfonyStyle, - new DeprecatedRulesReporter($symfonyStyle, []), + new DeprecatedRulesReporter($symfonyStyle), new MissConfigurationReporter( $symfonyStyle, new VendorMissAnalyseGuard(),