Skip to content

Commit

Permalink
[Php54] Add MethodCall and StaticCall support on RemoveReferenceFromC…
Browse files Browse the repository at this point in the history
…allRector (#2553)

* [Php54] Add MethodCall and StaticCall on RemoveReferenceFromCallRector

* implemented 🎉
  • Loading branch information
samsonasik committed Jun 22, 2022
1 parent 6c0332c commit 574e000
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 3 deletions.
@@ -0,0 +1,27 @@
<?php

namespace Rector\Tests\Php54\Rector\FuncCall\RemoveReferenceFromCallRector\Fixture;

class SomeMethodCall
{
function removeReference($one)
{
return $this->bar(&$one);
}
}

?>
-----
<?php

namespace Rector\Tests\Php54\Rector\FuncCall\RemoveReferenceFromCallRector\Fixture;

class SomeMethodCall
{
function removeReference($one)
{
return $this->bar($one);
}
}

?>
@@ -0,0 +1,27 @@
<?php

namespace Rector\Tests\Php54\Rector\FuncCall\RemoveReferenceFromCallRector\Fixture;

class SomeStaticCall
{
function removeReference($one)
{
return Foo::bar(&$one);
}
}

?>
-----
<?php

namespace Rector\Tests\Php54\Rector\FuncCall\RemoveReferenceFromCallRector\Fixture;

class SomeStaticCall
{
function removeReference($one)
{
return Foo::bar($one);
}
}

?>
8 changes: 5 additions & 3 deletions rules/Php54/Rector/FuncCall/RemoveReferenceFromCallRector.php
Expand Up @@ -7,6 +7,8 @@
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\StaticCall;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
Expand Down Expand Up @@ -55,13 +57,13 @@ public function run($one)
*/
public function getNodeTypes(): array
{
return [FuncCall::class];
return [FuncCall::class, MethodCall::class, StaticCall::class];
}

/**
* @param FuncCall $node
* @param FuncCall|MethodCall|StaticCall $node
*/
public function refactor(Node $node): FuncCall|null
public function refactor(Node $node): FuncCall|MethodCall|StaticCall|null
{
$hasChanged = false;

Expand Down

0 comments on commit 574e000

Please sign in to comment.