> */ private array $walkers = []; /** * {@inheritDoc} */ public function __construct( private readonly AbstractQuery $query, private readonly ParserResult $parserResult, private array $queryComponents, ) { } /** * Returns the internal queryComponents array. * * {@inheritDoc} */ public function getQueryComponents(): array { return $this->queryComponents; } /** * Adds a tree walker to the chain. * * @param string $walkerClass The class of the walker to instantiate. * @psalm-param class-string $walkerClass */ public function addTreeWalker(string $walkerClass): void { $this->walkers[] = $walkerClass; } public function walkSelectStatement(AST\SelectStatement $selectStatement): void { foreach ($this->getWalkers() as $walker) { $walker->walkSelectStatement($selectStatement); $this->queryComponents = $walker->getQueryComponents(); } } public function walkUpdateStatement(AST\UpdateStatement $updateStatement): void { foreach ($this->getWalkers() as $walker) { $walker->walkUpdateStatement($updateStatement); } } public function walkDeleteStatement(AST\DeleteStatement $deleteStatement): void { foreach ($this->getWalkers() as $walker) { $walker->walkDeleteStatement($deleteStatement); } } /** @psalm-return Generator */ private function getWalkers(): Generator { foreach ($this->walkers as $walkerClass) { yield new $walkerClass($this->query, $this->parserResult, $this->queryComponents); } } }