function NodeFinder::findFirst
Find first node 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
null|Node Found node (or null if none found)
1 call to NodeFinder::findFirst()
- NodeFinder::findFirstInstanceOf in vendor/
nikic/ php-parser/ lib/ PhpParser/ NodeFinder.php - Find first node that is an instance of a certain class.
File
-
vendor/
nikic/ php-parser/ lib/ PhpParser/ NodeFinder.php, line 58
Class
Namespace
PhpParserCode
public function findFirst($nodes, callable $filter) : ?Node {
if ($nodes === []) {
return null;
}
if (!is_array($nodes)) {
$nodes = [
$nodes,
];
}
$visitor = new FirstFindingVisitor($filter);
$traverser = new NodeTraverser($visitor);
$traverser->traverse($nodes);
return $visitor->getFoundNode();
}