public function find($type) { foreach ($this->children as $node) { if ($node->type === $type) { (yield $node); } foreach ($node->find($type) as $subNode) { (yield $subNode); } } }
/** * Collects all imports and handles them via ->handleImport. * * @param Node $node the root Node to search imports in * * @return $this * @throws Exception when the allowImports-options is set to false */ protected function handleImports(Node $node) { foreach ($node->find('import') as $importNode) { if (!$this->options['allowImports']) { $this->throwException('Imports are not allowed in this compiler instance', $node); } $this->handleImport($importNode); } return $this; }