Skip to content

Commit

Permalink
extend MethodCallRenameInterface contract with getClass() (#1129)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba authored Nov 2, 2021
1 parent df23327 commit 954ffad
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
4 changes: 3 additions & 1 deletion rules/Renaming/Contract/MethodCallRenameInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

interface MethodCallRenameInterface
{
public function getOldObjectType(): ObjectType;
public function getClass(): string;

public function getObjectType(): ObjectType;

public function getOldMethod(): string;

Expand Down
4 changes: 2 additions & 2 deletions rules/Renaming/Rector/MethodCall/RenameMethodRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function refactor(Node $node): ?Node
{
foreach ($this->methodCallRenames as $methodCallRename) {
$implementsInterface = $this->classManipulator->hasParentMethodOrInterface(
$methodCallRename->getOldObjectType(),
$methodCallRename->getObjectType(),
$methodCallRename->getOldMethod()
);
if ($implementsInterface) {
Expand All @@ -92,7 +92,7 @@ public function refactor(Node $node): ?Node

if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType(
$node,
$methodCallRename->getOldObjectType()
$methodCallRename->getObjectType()
)) {
continue;
}
Expand Down
11 changes: 8 additions & 3 deletions rules/Renaming/ValueObject/MethodCallRename.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@
final class MethodCallRename implements MethodCallRenameInterface
{
public function __construct(
private string $oldClass,
private string $class,
private string $oldMethod,
private string $newMethod
) {
}

public function getOldObjectType(): ObjectType
public function getClass(): string
{
return new ObjectType($this->oldClass);
return $this->class;
}

public function getObjectType(): ObjectType
{
return new ObjectType($this->class);
}

public function getOldMethod(): string
Expand Down
13 changes: 9 additions & 4 deletions rules/Renaming/ValueObject/MethodCallRenameWithArrayKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,21 @@ final class MethodCallRenameWithArrayKey implements MethodCallRenameInterface
* @param mixed $arrayKey
*/
public function __construct(
private string $oldClass,
private string $class,
private string $oldMethod,
private string $newMethod,
private $arrayKey
private $arrayKey
) {
}

public function getOldObjectType(): ObjectType
public function getClass(): string
{
return new ObjectType($this->oldClass);
return $this->class;
}

public function getObjectType(): ObjectType
{
return new ObjectType($this->class);
}

public function getOldMethod(): string
Expand Down

0 comments on commit 954ffad

Please sign in to comment.