Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. NodeFinder.php

function NodeFinder::find

Find all nodes satisfying a filter callback.

Parameters

Node|Node[] $nodes Single node or array of nodes to search in:

callable $filter Filter callback: function(Node $node) : bool:

Return value

Node[] Found nodes satisfying the filter callback

1 call to NodeFinder::find()
NodeFinder::findInstanceOf in vendor/nikic/php-parser/lib/PhpParser/NodeFinder.php
Find all nodes that are instances of a certain class.

File

vendor/nikic/php-parser/lib/PhpParser/NodeFinder.php, line 17

Class

NodeFinder

Namespace

PhpParser

Code

public function find($nodes, callable $filter) : array {
    if ($nodes === []) {
        return [];
    }
    if (!is_array($nodes)) {
        $nodes = [
            $nodes,
        ];
    }
    $visitor = new FindingVisitor($filter);
    $traverser = new NodeTraverser($visitor);
    $traverser->traverse($nodes);
    return $visitor->getFoundNodes();
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal