diff --git a/rules-tests/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/Fixture/fixture.php.inc b/rules-tests/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/Fixture/fixture.php.inc deleted file mode 100644 index 2fb203e7771..00000000000 --- a/rules-tests/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,31 +0,0 @@ -someMethod(); - } -} - -?> ------ -someProperty->someMethod(); - } -} - -?> diff --git a/rules-tests/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/ReplaceParentCallByPropertyCallRectorTest.php b/rules-tests/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/ReplaceParentCallByPropertyCallRectorTest.php deleted file mode 100644 index 47ab3749a23..00000000000 --- a/rules-tests/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/ReplaceParentCallByPropertyCallRectorTest.php +++ /dev/null @@ -1,28 +0,0 @@ -doTestFile($filePath); - } - - public static function provideData(): Iterator - { - return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - public function provideConfigFilePath(): string - { - return __DIR__ . '/config/configured_rule.php'; - } -} diff --git a/rules-tests/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/Source/TypeClassToReplaceMethodCallBy.php b/rules-tests/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/Source/TypeClassToReplaceMethodCallBy.php deleted file mode 100644 index 54e6663413b..00000000000 --- a/rules-tests/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector/Source/TypeClassToReplaceMethodCallBy.php +++ /dev/null @@ -1,10 +0,0 @@ -ruleWithConfiguration(ReplaceParentCallByPropertyCallRector::class, [ - new ReplaceParentCallByPropertyCall(TypeClassToReplaceMethodCallBy::class, 'someMethod', 'someProperty'), - ]); -}; diff --git a/rules/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector.php b/rules/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector.php index ed69d532059..4abe6b1b7a9 100644 --- a/rules/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector.php +++ b/rules/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector.php @@ -7,22 +7,17 @@ use PhpParser\Node; use PhpParser\Node\Expr\MethodCall; use Rector\Contract\Rector\ConfigurableRectorInterface; +use Rector\Exception\ShouldNotHappenException; use Rector\Rector\AbstractRector; use Rector\Transform\ValueObject\ReplaceParentCallByPropertyCall; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; -use Webmozart\Assert\Assert; /** - * @see \Rector\Tests\Transform\Rector\MethodCall\ReplaceParentCallByPropertyCallRector\ReplaceParentCallByPropertyCallRectorTest + * @deprecated as this rule was part of removed doctrine service set. It does not work as standalone. Create custom rule instead. */ final class ReplaceParentCallByPropertyCallRector extends AbstractRector implements ConfigurableRectorInterface { - /** - * @var ReplaceParentCallByPropertyCall[] - */ - private array $parentCallToProperties = []; - public function getRuleDefinition(): RuleDefinition { return new RuleDefinition( @@ -68,20 +63,10 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - foreach ($this->parentCallToProperties as $parentCallToProperty) { - if (! $this->isName($node->name, $parentCallToProperty->getMethod())) { - continue; - } - - if (! $this->isObjectType($node->var, $parentCallToProperty->getObjectType())) { - continue; - } - - $node->var = $this->nodeFactory->createPropertyFetch('this', $parentCallToProperty->getProperty()); - return $node; - } - - return null; + throw new ShouldNotHappenException(sprintf( + 'This Rector "%s" is deprecated as it was part of removed doctrine service set. It does not work as standalone. Create custom rule instead.', + self::class + )); } /** @@ -89,8 +74,5 @@ public function refactor(Node $node): ?Node */ public function configure(array $configuration): void { - Assert::allIsAOf($configuration, ReplaceParentCallByPropertyCall::class); - - $this->parentCallToProperties = $configuration; } } diff --git a/rules/Transform/ValueObject/ReplaceParentCallByPropertyCall.php b/rules/Transform/ValueObject/ReplaceParentCallByPropertyCall.php index bdaa4918f4d..eb9cc62855b 100644 --- a/rules/Transform/ValueObject/ReplaceParentCallByPropertyCall.php +++ b/rules/Transform/ValueObject/ReplaceParentCallByPropertyCall.php @@ -7,6 +7,9 @@ use PHPStan\Type\ObjectType; use Rector\Validation\RectorAssert; +/** + * @deprecated as related rule is deprecated + */ final readonly class ReplaceParentCallByPropertyCall { public function __construct(