packages/sql-semantics/src/Analyzer.php
1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics;
6
7/**
8 * Analyzes SQL under a database-specific language profile.
9 *
10 * @visibility public
11 * @example Accepting an analyzer from any database package
12 * $render = static fn (\SqlSemantics\Analyzer $analyzer, string $sql): string => $analyzer->analyze($sql)->toString();
13 * is_callable($render) // => true
14 */
15interface Analyzer
16{
17 /**
18 * Analyzes SQL against the supplied declaration context or an open context.
19 *
20 * @throws AnalysisException When the SQL is rejected or the context is incompatible
21 */
22 public function analyze(string $sql, ?AnalysisContext $context = null): Query;
23}
24