rector/rules/Naming/Matcher/CallMatcher.php
Tomas Votruba d56e7982d0 Updated Rector to commit dedd4b55fe3e03cae9bd5ac822cfdccd8deb3fb6
dedd4b55fe make node_helper.php safe for similar names
2021-05-09 20:15:43 +00:00

32 lines
829 B
PHP

<?php
declare (strict_types=1);
namespace Rector\Naming\Matcher;
use PhpParser\Node;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Stmt\Foreach_;
final class CallMatcher
{
/**
* @param Assign|Foreach_ $node
* @return FuncCall|StaticCall|MethodCall|null
*/
public function matchCall(\PhpParser\Node $node) : ?\PhpParser\Node
{
if ($node->expr instanceof \PhpParser\Node\Expr\MethodCall) {
return $node->expr;
}
if ($node->expr instanceof \PhpParser\Node\Expr\StaticCall) {
return $node->expr;
}
if ($node->expr instanceof \PhpParser\Node\Expr\FuncCall) {
return $node->expr;
}
return null;
}
}