Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -68,29 +63,16 @@ 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
));
}

/**
* @param mixed[] $configuration
*/
public function configure(array $configuration): void
{
Assert::allIsAOf($configuration, ReplaceParentCallByPropertyCall::class);

$this->parentCallToProperties = $configuration;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down