mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-03 01:40:49 +00:00
7ec53f4a70
e6fd26353f
Get rid of in the (#3780)
36 lines
921 B
PHP
36 lines
921 B
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\NodeNameResolver\NodeNameResolver;
|
|
|
|
use PhpParser\Node;
|
|
use PhpParser\Node\Stmt\Function_;
|
|
use PHPStan\Analyser\Scope;
|
|
use Rector\NodeNameResolver\Contract\NodeNameResolverInterface;
|
|
use Rector\NodeTypeResolver\Node\AttributeKey;
|
|
/**
|
|
* @implements NodeNameResolverInterface<Function_>
|
|
*/
|
|
final class FunctionNameResolver implements NodeNameResolverInterface
|
|
{
|
|
public function getNode() : string
|
|
{
|
|
return Function_::class;
|
|
}
|
|
/**
|
|
* @param Function_ $node
|
|
*/
|
|
public function resolve(Node $node, ?Scope $scope) : ?string
|
|
{
|
|
$bareName = (string) $node->name;
|
|
if (!$scope instanceof Scope) {
|
|
return $bareName;
|
|
}
|
|
$namespaceName = $scope->getNamespace();
|
|
if ($namespaceName !== null) {
|
|
return $namespaceName . '\\' . $bareName;
|
|
}
|
|
return $bareName;
|
|
}
|
|
}
|