3 namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Indexer;
5 use Drupal\drupalmoduleupgrader\IndexerBase;
8 use Pharborist\Functions\FunctionCallNode;
9 use Pharborist\NodeCollection;
13 * id = "function_call",
14 * description = @Translation("Indexes all function calls in a target module."),
18 class FunctionCalls extends IndexerBase {
23 public function build() {
24 /** @var \Symfony\Component\Finder\SplFileInfo $file */
25 foreach ($this->target->getFinder() as $file) {
26 $path = $file->getPathname();
30 ->find(Filter::isInstanceOf('\Pharborist\Functions\FunctionCallNode'))
31 ->not(function(FunctionCallNode $function_call) {
32 return in_array($function_call->getName()->getText(), $this->pluginDefinition['exclude']);
34 ->each([ $this, 'add' ]);
41 public function get($id) {
42 $all = new NodeCollection([]);
47 ->condition('id', $id)
51 array_walk($files, function($file) use ($all, $id) {
52 $all->add($this->target->open($file)->find(Filter::isFunctionCall($id)));
61 public function addFile($path) {
62 $doc = Parser::parseFile($path);
65 ->find(Filter::isInstanceOf('\Pharborist\Functions\FunctionCallNode'))
66 ->each([ $this, 'add' ]);