final class LexicalException
    extends RuntimeException
Public API: explicitly declared with @visibility public.

Reports missing lexical definitions, incompatible candidates and diagnostic tokenizer failures.

Generation checks source-derived lexical and spacing conditions before serialization. Tokenizer diagnostics remain available separately; token equality is not the acceptance oracle.

Catch this failure as a runtime exceptiondoctest
$failure = new \SqlFaker\Generation\Exception\LexicalException('SQL generation failed');
    $failure instanceof \RuntimeException // => true
    $failure->getMessage() // => 'SQL generation failed'

Methods§

public static function unsupportedTerminal(
    string $dialect,
    string $version,
    string $terminal,
): self
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.

Reports a terminal without an applicable lexical generator.

Parameters

$dialectstringDialect label supplied by the calling implementation
$versionstringLexical profile version in use
$terminalstringTerminal that was asked for

Returns

self Exception naming the terminal and the profile
Test cases 2
Called from 1
Calls 1
public static function unsupportedInput(string $dialect, int $offset, string $sql): self
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.

Reports SQL text the tokenizer cannot read at all.

Parameters

$dialectstringDialect name as it appears in messages
$offsetintWhere the tokenizer stopped
$sqlstringThe text being read

Returns

self Exception naming the offset and the text
Test cases 2
Called from 3
Calls 1
public static function noProgress(string $dialect, int $offset, string $sql): self
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.

Reports a read that did not get past where it started.

A scanner that stays where it is has not read anything, and the loop around it would run forever. Saying so at the point it happens turns a hang into a failure that names the offset it happened at.

Parameters

$dialectstringDialect name as it appears in messages
$offsetintOffset the read started and ended at
$sqlstringThe text being read

Returns

self Exception naming the offset and the text
Test cases 1
Called from 6
Calls 1
public static function unterminatedQuotedToken(string $dialect, string $sql): self
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.

Reports a quoted run that never closes.

Parameters

$dialectstringDialect name as it appears in messages
$sqlstringThe text being read

Returns

self Exception naming the text
Test cases 1
Called from 3
Calls 1
public static function unterminatedBracketIdentifier(string $dialect): self
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.

Reports a bracketed identifier that never closes.

Parameters

$dialectstringDialect name as it appears in messages

Returns

self Exception describing the truncation
Test cases 1
Called from 1
Calls 1
public static function unterminatedBlockComment(string $dialect): self
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.

Reports a block comment that never closes.

Parameters

$dialectstringDialect name as it appears in messages

Returns

self Exception describing the truncation
Test cases 1
Called from 3
Calls 1
public static function unterminatedDollarQuotedString(string $dialect): self
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.

Reports a dollar-quoted string that never closes.

Parameters

$dialectstringDialect name as it appears in messages

Returns

self Exception describing the truncation
Test cases 1
Called from 2
Calls 1
public static function lexemeDoesNotRealizeTerminal(
    string $dialect,
    string $terminal,
    string $lexeme,
): self
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.

Reports a caller-supplied lexeme that does not tokenize to the terminal it was given for.

Parameters

$dialectstringDialect name as it appears in messages
$terminalstringTerminal the lexeme was meant to realize
$lexemestringThe text the caller asked for

Returns

self Exception naming the terminal and the text
Test cases 1
Calls 1
public static function noWitnessForLexeme(
    string $dialect,
    string $terminal,
    string $lexeme,
): self
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.

Formats a legacy lexical-catalog diagnostic for callers retaining such reports.

Parameters

$dialectstringDialect name as it appears in messages
$terminalstringTerminal the lexeme was meant to realize
$lexemestringThe text the caller asked for

Returns

self Exception naming the terminal and the text
Test cases 1
Calls 1
public static function roundTripMismatch(
    string $dialect,
    string $version,
    list<string> $expected,
    list<string> $actual,
    string $sql,
): self
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.

Reports SQL that did not tokenize back to the terminals it was generated from.

This diagnostic compares a generated token sequence with a local tokenizer. It does not determine whether the target database accepts the SQL.

Parameters

$dialectstringDialect name as it appears in messages
$versionstringLexical profile version in use
$expectedlist<string>Tokens the terminals were meant to produce
$actuallist<string>Tokens the text actually produced
$sqlstringThe generated text

Returns

self Exception carrying both sequences and the text
Test cases 1
Calls 3
public static function rendered(list<string> $tokens): string
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.

Renders a token sequence for a failure message.

The sequences being compared came out of arbitrary generated bytes, so rendering them can meet input JSON has no encoding for. Substituting those bytes keeps the round-trip failure reportable: a message that could itself fail would hide the thing worth reporting behind an encoding error.

Parameters

$tokenslist<string>Tokens to render

Returns

string The sequence as JSON, or a placeholder when it cannot be rendered
Test cases 3
Called from 2
Calls 2

Test cases 61§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 14
Other tests reaching this symbol 47

Relations§

Instantiated in 7
Static calls 19