Skip to content

Commit 68dd40a

Browse files
committed
Deprecate StaticToSelfStaticMethodCallOnFinalClassRector and ConvertStaticPrivateConstantToSelfRector
1 parent 1dafa98 commit 68dd40a

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

rules/CodeQuality/Rector/ClassConstFetch/ConvertStaticPrivateConstantToSelfRector.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use PhpParser\Node;
88
use PhpParser\Node\Stmt\Class_;
99
use Rector\CodeQuality\Rector\Class_\ConvertStaticToSelfRector;
10+
use Rector\Exception\ShouldNotHappenException;
1011
use Rector\Rector\AbstractRector;
1112
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
1213
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@@ -16,11 +17,6 @@
1617
*/
1718
final class ConvertStaticPrivateConstantToSelfRector extends AbstractRector
1819
{
19-
public function __construct(
20-
private readonly ConvertStaticToSelfRector $convertStaticToSelfRector
21-
) {
22-
}
23-
2420
public function getRuleDefinition(): RuleDefinition
2521
{
2622
return new RuleDefinition(
@@ -72,6 +68,10 @@ public function getNodeTypes(): array
7268
*/
7369
public function refactor(Node $node): ?Class_
7470
{
75-
return $this->convertStaticToSelfRector->refactor($node);
71+
throw new ShouldNotHappenException(sprintf(
72+
'The % rule is deprecated. Use %s instead',
73+
self::class,
74+
ConvertStaticToSelfRector::class,
75+
));
7676
}
7777
}

rules/CodeQuality/Rector/Class_/StaticToSelfStaticMethodCallOnFinalClassRector.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use PhpParser\Node;
88
use PhpParser\Node\Stmt\Class_;
9+
use Rector\Exception\ShouldNotHappenException;
910
use Rector\Rector\AbstractRector;
1011
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
1112
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@@ -15,11 +16,6 @@
1516
*/
1617
final class StaticToSelfStaticMethodCallOnFinalClassRector extends AbstractRector
1718
{
18-
public function __construct(
19-
private readonly ConvertStaticToSelfRector $convertStaticToSelfRector
20-
) {
21-
}
22-
2319
public function getRuleDefinition(): RuleDefinition
2420
{
2521
return new RuleDefinition('Change `static::methodCall()` to `self::methodCall()` on final class', [
@@ -70,6 +66,10 @@ public function getNodeTypes(): array
7066
*/
7167
public function refactor(Node $node): ?Class_
7268
{
73-
return $this->convertStaticToSelfRector->refactor($node);
69+
throw new ShouldNotHappenException(sprintf(
70+
'The % rule is deprecated. Use %s instead',
71+
self::class,
72+
ConvertStaticToSelfRector::class,
73+
));
7474
}
7575
}

0 commit comments

Comments
 (0)