[Generic] skip static method in FuncCallToMethodCallRector (#3901)

This commit is contained in:
Tomas Votruba 2020-08-04 15:37:29 +02:00 committed by GitHub
parent b2054a32fc
commit f322e4110c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -9,6 +9,7 @@ use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\RectorDefinition\ConfiguredCodeSample;
@ -112,6 +113,15 @@ CODE_SAMPLE
return null;
}
$classMethod = $node->getAttribute(AttributeKey::METHOD_NODE);
if (! $classMethod instanceof ClassMethod) {
return null;
}
if ($classMethod->isStatic()) {
return null;
}
foreach ($this->functionToClassToMethod as $function => $classMethod) {
if (! $this->isName($node->name, $function)) {
continue;

View File

@ -0,0 +1,13 @@
<?php
namespace Rector\Generic\Tests\Rector\FuncCall\FuncCallToMethodCallRector\Fixture;
use function Rector\Generic\Tests\Rector\FuncCall\FuncCallToMethodCallRector\Source\some_view_function;
final class SkipStaticMethod
{
public static function run()
{
$result = \translate('name');
}
}