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
Namespace
PhpParserCode
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();
}