-
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reverts Use MethodCallRename directly (#3080)
- Loading branch information
1 parent
24b9eb7
commit 6c7caa6
Showing
9 changed files
with
156 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
rules-tests/Renaming/Rector/MethodCall/RenameMethodRector/Fixture/rename_method_call.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Renaming\Rector\MethodCall\RenameMethodRector\Fixture; | ||
|
||
class RenameMethodCall | ||
{ | ||
private function createHtml() | ||
{ | ||
$html = new \Nette\Utils\Html(); | ||
$html->add('someContent'); | ||
|
||
$anotherHtml = $html; | ||
$anotherHtml->add('someContent'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Renaming\Rector\MethodCall\RenameMethodRector\Fixture; | ||
|
||
class RenameMethodCall | ||
{ | ||
private function createHtml() | ||
{ | ||
$html = new \Nette\Utils\Html(); | ||
$html->addHtml('someContent'); | ||
|
||
$anotherHtml = $html; | ||
$anotherHtml->addHtml('someContent'); | ||
} | ||
} | ||
|
||
?> |
29 changes: 29 additions & 0 deletions
29
...ng/Rector/MethodCall/RenameMethodRector/Fixture/rename_method_call_with_array_key.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Renaming\Rector\MethodCall\RenameMethodRector\Fixture; | ||
|
||
class RenameMethodCallWithArrayKey | ||
{ | ||
private function createHtml() | ||
{ | ||
$html = new \Nette\Utils\Html(); | ||
$html->addToArray('someContent'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Renaming\Rector\MethodCall\RenameMethodRector\Fixture; | ||
|
||
class RenameMethodCallWithArrayKey | ||
{ | ||
private function createHtml() | ||
{ | ||
$html = new \Nette\Utils\Html(); | ||
$html->addToHtmlArray('someContent')['hey']; | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Renaming\Contract; | ||
|
||
use PHPStan\Type\ObjectType; | ||
|
||
interface MethodCallRenameInterface | ||
{ | ||
public function getClass(): string; | ||
|
||
public function getObjectType(): ObjectType; | ||
|
||
public function getOldMethod(): string; | ||
|
||
public function getNewMethod(): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
rules/Renaming/ValueObject/MethodCallRenameWithArrayKey.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Renaming\ValueObject; | ||
|
||
use PHPStan\Type\ObjectType; | ||
use Rector\Core\Validation\RectorAssert; | ||
use Rector\Renaming\Contract\MethodCallRenameInterface; | ||
|
||
final class MethodCallRenameWithArrayKey implements MethodCallRenameInterface | ||
{ | ||
public function __construct( | ||
private readonly string $class, | ||
private readonly string $oldMethod, | ||
private readonly string $newMethod, | ||
private readonly mixed $arrayKey | ||
) { | ||
RectorAssert::className($class); | ||
RectorAssert::methodName($oldMethod); | ||
RectorAssert::methodName($newMethod); | ||
} | ||
|
||
public function getClass(): string | ||
{ | ||
return $this->class; | ||
} | ||
|
||
public function getObjectType(): ObjectType | ||
{ | ||
return new ObjectType($this->class); | ||
} | ||
|
||
public function getOldMethod(): string | ||
{ | ||
return $this->oldMethod; | ||
} | ||
|
||
public function getNewMethod(): string | ||
{ | ||
return $this->newMethod; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getArrayKey() | ||
{ | ||
return $this->arrayKey; | ||
} | ||
} |