php-extension-check/src/Parser/Visitors/FunctionCollector.php
2021-05-09 00:50:26 +02:00

36 líneas
771 B
PHP

<?php
declare(strict_types=1);
namespace Fbrinker\ExtensionCheck\Parser\Visitors;
use PhpParser\Node;
use PhpParser\NodeVisitorAbstract;
class FunctionCollector extends NodeVisitorAbstract implements CollectorInferface
{
/**
* @var array<string,bool> $functions
*/
private $functions = [];
public function getCollected(): array
{
$list = array_keys($this->functions);
natcasesort($list);
return array_values($list);
}
public function enterNode(Node $node)
{
if ($node instanceof Node\Expr\FuncCall) {
if (!empty($node->name) && $node->name instanceof Node\Name) {
$this->functions[$node->name->toString()] = true;
}
}
return null;
}
}