|
7 | 7 | use PhpParser\Node; |
8 | 8 | use PhpParser\Node\Expr\MethodCall; |
9 | 9 | use Rector\Contract\Rector\ConfigurableRectorInterface; |
| 10 | +use Rector\Exception\ShouldNotHappenException; |
10 | 11 | use Rector\Rector\AbstractRector; |
11 | 12 | use Rector\Transform\ValueObject\ReplaceParentCallByPropertyCall; |
12 | 13 | use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; |
13 | 14 | use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; |
14 | | -use Webmozart\Assert\Assert; |
15 | 15 |
|
16 | 16 | /** |
17 | | - * @see \Rector\Tests\Transform\Rector\MethodCall\ReplaceParentCallByPropertyCallRector\ReplaceParentCallByPropertyCallRectorTest |
| 17 | + * @deprecated as this rule was part of removed doctrine service set. It does not work as standalone. Create custom rule instead. |
18 | 18 | */ |
19 | 19 | final class ReplaceParentCallByPropertyCallRector extends AbstractRector implements ConfigurableRectorInterface |
20 | 20 | { |
21 | | - /** |
22 | | - * @var ReplaceParentCallByPropertyCall[] |
23 | | - */ |
24 | | - private array $parentCallToProperties = []; |
25 | | - |
26 | 21 | public function getRuleDefinition(): RuleDefinition |
27 | 22 | { |
28 | 23 | return new RuleDefinition( |
@@ -68,29 +63,16 @@ public function getNodeTypes(): array |
68 | 63 | */ |
69 | 64 | public function refactor(Node $node): ?Node |
70 | 65 | { |
71 | | - foreach ($this->parentCallToProperties as $parentCallToProperty) { |
72 | | - if (! $this->isName($node->name, $parentCallToProperty->getMethod())) { |
73 | | - continue; |
74 | | - } |
75 | | - |
76 | | - if (! $this->isObjectType($node->var, $parentCallToProperty->getObjectType())) { |
77 | | - continue; |
78 | | - } |
79 | | - |
80 | | - $node->var = $this->nodeFactory->createPropertyFetch('this', $parentCallToProperty->getProperty()); |
81 | | - return $node; |
82 | | - } |
83 | | - |
84 | | - return null; |
| 66 | + throw new ShouldNotHappenException(sprintf( |
| 67 | + 'This Rector "%s" is deprecated as it was part of removed doctrine service set. It does not work as standalone. Create custom rule instead.', |
| 68 | + self::class |
| 69 | + )); |
85 | 70 | } |
86 | 71 |
|
87 | 72 | /** |
88 | 73 | * @param mixed[] $configuration |
89 | 74 | */ |
90 | 75 | public function configure(array $configuration): void |
91 | 76 | { |
92 | | - Assert::allIsAOf($configuration, ReplaceParentCallByPropertyCall::class); |
93 | | - |
94 | | - $this->parentCallToProperties = $configuration; |
95 | 77 | } |
96 | 78 | } |
0 commit comments