Skip to content

Commit f951c9a

Browse files
committed
[Configuration] Use deprecated rule stub in test to avoid deprecated class reference
1 parent 40f9239 commit f951c9a

2 files changed

Lines changed: 33 additions & 3 deletions

File tree

‎tests/Configuration/ConfigurationRuleFilterTest.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Rector\DeadCode\Rector\If_\RemoveDeadInstanceOfRector;
99
use Rector\Php80\Rector\Class_\StringableForToStringRector;
1010
use Rector\Testing\PHPUnit\AbstractLazyTestCase;
11-
use Rector\Transform\Rector\Class_\AddInterfaceByTraitRector;
11+
use Rector\Tests\Configuration\Source\DeprecatedRectorStub;
1212
use Rector\ValueObject\Configuration;
1313

1414
final class ConfigurationRuleFilterTest extends AbstractLazyTestCase
@@ -53,12 +53,12 @@ public function testWithoutPhpOnlyKeepsAllRules(): void
5353
public function testFiltersOutDeprecatedRules(): void
5454
{
5555
$removeDeadInstanceOfRector = $this->make(RemoveDeadInstanceOfRector::class);
56-
$addInterfaceByTraitRector = $this->make(AddInterfaceByTraitRector::class);
56+
$deprecatedRectorStub = $this->make(DeprecatedRectorStub::class);
5757

5858
$this->configurationRuleFilter->setConfiguration($this->createConfiguration(false));
5959

6060
$filteredRectors = $this->configurationRuleFilter->filter(
61-
[$removeDeadInstanceOfRector, $addInterfaceByTraitRector]
61+
[$removeDeadInstanceOfRector, $deprecatedRectorStub]
6262
);
6363

6464
$this->assertSame([$removeDeadInstanceOfRector], $filteredRectors);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\Tests\Configuration\Source;
6+
7+
use PhpParser\Node;
8+
use PhpParser\Node\Stmt\Class_;
9+
use Rector\Configuration\Deprecation\Contract\DeprecatedInterface;
10+
use Rector\Rector\AbstractRector;
11+
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
12+
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
13+
14+
final class DeprecatedRectorStub extends AbstractRector implements DeprecatedInterface
15+
{
16+
public function getRuleDefinition(): RuleDefinition
17+
{
18+
return new RuleDefinition('Deprecated stub rule for tests', [new CodeSample('before', 'after')]);
19+
}
20+
21+
public function getNodeTypes(): array
22+
{
23+
return [Class_::class];
24+
}
25+
26+
public function refactor(Node $node): ?Node
27+
{
28+
return null;
29+
}
30+
}

0 commit comments

Comments
 (0)