Skip to content

Commit eb70369

Browse files
authored
[traversing] Remove deprecated beforeTraverse method reporter (#8542)
1 parent a30fb96 commit eb70369

5 files changed

Lines changed: 2 additions & 35 deletions

File tree

‎phpstan.neon‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,6 @@ parameters:
325325
- src/Configuration/RectorConfigBuilder.php
326326
- src/Validation/RectorConfigValidator.php
327327
- src/Testing/PHPUnit/AbstractLazyTestCase.php
328-
- src/Reporting/DeprecatedRulesReporter.php
329328
- src/Configuration/OnlyRuleResolver.php
330329

331330
# debug and internal functions

‎src/Console/Command/ProcessCommand.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
195195
// 4. Deprecations reporter
196196
$this->deprecatedRulesReporter->reportDeprecatedRules();
197197
$this->deprecatedRulesReporter->reportDeprecatedSkippedRules();
198-
$this->deprecatedRulesReporter->reportDeprecatedRectorUnsupportedMethods();
199198
$this->deprecatedRulesReporter->reportDeprecatedCacheMetaExtensions();
200199
$this->deprecatedRulesReporter->reportDeprecatedPhpSetsMethods();
201200
$this->deprecatedRulesReporter->reportDeprecatedAttributesSetsArgs();

‎src/Console/Command/ValidateConfigCommand.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6363
$issueCount += $this->deprecatedRulesReporter->reportDeprecatedPhpSetsMethods();
6464
$issueCount += $this->deprecatedRulesReporter->reportDeprecatedAttributesSetsArgs();
6565
$issueCount += $this->deprecatedRulesReporter->reportDeprecatedComposerBasedArgs();
66-
$issueCount += $this->deprecatedRulesReporter->reportDeprecatedRectorUnsupportedMethods();
6766

6867
$issueCount += $this->missConfigurationReporter->reportSkippedNeverRegisteredRules();
6968
$issueCount += $this->missConfigurationReporter->reportSkippedNonRectorClasses();

‎src/Reporting/DeprecatedRulesReporter.php‎

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,12 @@
77
use Rector\Configuration\Deprecation\Contract\DeprecatedInterface;
88
use Rector\Configuration\Option;
99
use Rector\Configuration\Parameter\SimpleParameterProvider;
10-
use Rector\Contract\Rector\RectorInterface;
11-
use Rector\PhpParser\Node\FileNode;
12-
use ReflectionMethod;
1310
use Symfony\Component\Console\Style\SymfonyStyle;
1411

1512
final readonly class DeprecatedRulesReporter
1613
{
17-
/**
18-
* @param RectorInterface[] $rectors
19-
*/
2014
public function __construct(
21-
private SymfonyStyle $symfonyStyle,
22-
private array $rectors
15+
private SymfonyStyle $symfonyStyle
2316
) {
2417
}
2518

@@ -137,27 +130,4 @@ public function reportDeprecatedComposerBasedArgs(): int
137130

138131
return $reportedCount;
139132
}
140-
141-
public function reportDeprecatedRectorUnsupportedMethods(): int
142-
{
143-
// to be added in related PR
144-
if (! class_exists(FileNode::class)) {
145-
return 0;
146-
}
147-
148-
$reportedCount = 0;
149-
foreach ($this->rectors as $rector) {
150-
$beforeTraverseMethodReflection = new ReflectionMethod($rector, 'beforeTraverse');
151-
if ($beforeTraverseMethodReflection->getDeclaringClass()->getName() === $rector::class) {
152-
$this->symfonyStyle->warning(sprintf(
153-
'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.',
154-
$rector::class,
155-
FileNode::class
156-
));
157-
++$reportedCount;
158-
}
159-
}
160-
161-
return $reportedCount;
162-
}
163133
}

‎tests/Console/Command/ValidateConfigCommandTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected function setUp(): void
5050

5151
$validateConfigCommand = new ValidateConfigCommand(
5252
$symfonyStyle,
53-
new DeprecatedRulesReporter($symfonyStyle, []),
53+
new DeprecatedRulesReporter($symfonyStyle),
5454
new MissConfigurationReporter(
5555
$symfonyStyle,
5656
new VendorMissAnalyseGuard(),

0 commit comments

Comments
 (0)