mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-25 20:32:35 +00:00
[Renaming] Handle RenameMethodRector on new in caller class (#5493)
Co-authored-by: Ruud Kamphuis <ruudk@users.noreply.github.com>
This commit is contained in:
parent
a3299830fc
commit
99e5d0a210
|
@ -139,6 +139,14 @@ CODE_SAMPLE
|
|||
|
||||
private function shouldSkipForExactClassMethodForClassMethod(ClassMethod $classMethod, string $type): bool
|
||||
{
|
||||
$className = $classMethod->getAttribute(AttributeKey::CLASS_NAME);
|
||||
$methodCalls = $this->nodeRepository->findMethodCallsOnClass($className);
|
||||
|
||||
$name = $this->getName($classMethod->name);
|
||||
if (isset($methodCalls[$name])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $classMethod->getAttribute(AttributeKey::CLASS_NAME) === $type;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace Rector\Renaming\Tests\Rector\MethodCall\RenameMethodRector\Fixture;
|
||||
|
||||
final class DemoFile
|
||||
{
|
||||
public function notify()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
final class Caller
|
||||
{
|
||||
public static function execute()
|
||||
{
|
||||
$demo = new DemoFile();
|
||||
$demo->notify();
|
||||
}
|
||||
}
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\Renaming\Tests\Rector\MethodCall\RenameMethodRector\Fixture;
|
||||
|
||||
final class DemoFile
|
||||
{
|
||||
public function __invoke()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
final class Caller
|
||||
{
|
||||
public static function execute()
|
||||
{
|
||||
$demo = new DemoFile();
|
||||
$demo->__invoke();
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -14,6 +14,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
RenameMethodRector::METHOD_CALL_RENAMES => ValueObjectInliner::inline([
|
||||
new MethodCallRename(AbstractType::class, 'setDefaultOptions', 'configureOptions'),
|
||||
new MethodCallRename(Html::class, 'add', 'addHtml'),
|
||||
new MethodCallRename('Rector\Renaming\Tests\Rector\MethodCall\RenameMethodRector\Fixture\DemoFile', 'notify', '__invoke'),
|
||||
new MethodCallRename('*Presenter', 'run', '__invoke'),
|
||||
new MethodCallRename(
|
||||
\Rector\Renaming\Tests\Rector\MethodCall\RenameMethodRector\Fixture\SkipSelfMethodRename::class,
|
||||
|
|
Loading…
Reference in New Issue
Block a user