packages/sql-semantics-postgres/src/Model/Diagnostic/ImplementationGap.php
1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Platform\PostgreSql\Model\Diagnostic;
6
7use LogicException;
8use SqlSemantics\Platform\PostgreSql\Model\Lowering\Form;
9
10/**
11 * A structuring, derivation, or rendering rule that the library has not implemented.
12 *
13 * It is a defect of the library and never a property of the SQL: grammatical
14 * input must not be turned into an unknown value or a rejection because a rule
15 * is absent.
16 *
17 * @visibility public
18 * @example Naming the production that has no rule
19 * \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\ImplementationGap::rule('cmd: PRAGMA nm')->getMessage() // => 'No semantic rule is implemented for: cmd: PRAGMA nm'
20 */
21final class ImplementationGap extends LogicException
22{
23 /**
24 * Reports a grammar production no lowering rule claims.
25 */
26 public static function production(Form $form): self
27 {
28 return self::rule($form->signature);
29 }
30
31 /**
32 * Reports a named rule obligation that has no implementation.
33 */
34 public static function rule(string $obligation): self
35 {
36 return new self('No semantic rule is implemented for: ' . $obligation);
37 }
38}
39