filterCallback = $filterCallback; } /** * Get found nodes satisfying the filter callback. * * Nodes are returned in pre-order. * * @return Node[] Found nodes */ public function getFoundNodes(): array { return $this->foundNodes; } public function beforeTraverse(array $nodes): ?array { $this->foundNodes = []; return null; } public function enterNode(Node $node) { $filterCallback = $this->filterCallback; if ($filterCallback($node)) { $this->foundNodes[] = $node; } return null; } }