Skip to content

Commit 3c9099b

Browse files
authored
[depre] Deprecate ReplaceParentCallByPropertyCallRector as not used since doctrine set service removed, not standalone rule (#7554)
1 parent 8878a14 commit 3c9099b

6 files changed

Lines changed: 9 additions & 108 deletions

File tree

rules-tests/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/Fixture/fixture.php.inc

Lines changed: 0 additions & 31 deletions
This file was deleted.

rules-tests/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/ReplaceParentCallByPropertyCallRectorTest.php

Lines changed: 0 additions & 28 deletions
This file was deleted.

rules-tests/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/Source/TypeClassToReplaceMethodCallBy.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

rules-tests/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/config/configured_rule.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

rules/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector.php

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,17 @@
77
use PhpParser\Node;
88
use PhpParser\Node\Expr\MethodCall;
99
use Rector\Contract\Rector\ConfigurableRectorInterface;
10+
use Rector\Exception\ShouldNotHappenException;
1011
use Rector\Rector\AbstractRector;
1112
use Rector\Transform\ValueObject\ReplaceParentCallByPropertyCall;
1213
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
1314
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
14-
use Webmozart\Assert\Assert;
1515

1616
/**
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.
1818
*/
1919
final class ReplaceParentCallByPropertyCallRector extends AbstractRector implements ConfigurableRectorInterface
2020
{
21-
/**
22-
* @var ReplaceParentCallByPropertyCall[]
23-
*/
24-
private array $parentCallToProperties = [];
25-
2621
public function getRuleDefinition(): RuleDefinition
2722
{
2823
return new RuleDefinition(
@@ -68,29 +63,16 @@ public function getNodeTypes(): array
6863
*/
6964
public function refactor(Node $node): ?Node
7065
{
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+
));
8570
}
8671

8772
/**
8873
* @param mixed[] $configuration
8974
*/
9075
public function configure(array $configuration): void
9176
{
92-
Assert::allIsAOf($configuration, ReplaceParentCallByPropertyCall::class);
93-
94-
$this->parentCallToProperties = $configuration;
9577
}
9678
}

rules/Transform/ValueObject/ReplaceParentCallByPropertyCall.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
use PHPStan\Type\ObjectType;
88
use Rector\Validation\RectorAssert;
99

10+
/**
11+
* @deprecated as related rule is deprecated
12+
*/
1013
final readonly class ReplaceParentCallByPropertyCall
1114
{
1215
public function __construct(

0 commit comments

Comments
 (0)