packages/sql-catalog/src/Core/Evaluation/Term.php

1<?php
2
3declare(strict_types=1);
4
5namespace SqlCatalog\Core\Evaluation;
6
7use SqlCatalog\Core\Text\TextPattern;
8use SqlCatalog\Core\Type\TypeShape;
9
10/**
11 * One alternative an expression may evaluate to.
12 *
13 * The hierarchy is sealed. A term is a resolved scalar (`LiteralTerm`), a
14 * string with gaps (`PatternTerm`), an array (`ArrayTerm`), an object
15 * (`ObjectTerm`), or a value known only by its type (`OpaqueTerm`).
16 *
17 * @visibility root
18 */
19interface Term
20{
21    /**
22     * The term written as the string PHP would splice into a query.
23     */
24    public function toPattern(): TextPattern;
25
26    /**
27     * The static type of the values this term stands for.
28     */
29    public function type(): TypeShape;
30
31    /**
32     * A canonical string used to deduplicate alternatives.
33     */
34    public function signature(): string;
35}
36