php-extension-check/src/Parser/Visitors/FunctionCollector.php

25 خطوط
682 B
PHP

2021-05-08 21:09:48 +00:00
<?php
declare(strict_types=1);
namespace Fbrinker\ExtensionCheck\Parser\Visitors;
use PhpParser\Node;
use PhpParser\NodeVisitorAbstract;
class FunctionCollector extends NodeVisitorAbstract implements CollectorInferface {
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;
}
}
}
}