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

Reports that a grammar could not derive a statement.

A rule with no alternatives, an alternative no lexer can realize, a reference to a rule the grammar does not define, or a derivation that runs past its depth limit are all properties of the grammar being generated from, not of the generator. Callers that generate from grammars they did not author are expected to handle this.

The three dialect generators hit the same failures, so the wording lives here rather than being repeated at each throw site.

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

Methods§

public static function unknownRule(string $rule): self
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.

Reports a reference to a rule the grammar does not define.

Parameters

$rulestringName the production referred to

Returns

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

Reports a rule that declares no alternatives to choose from.

Parameters

$rulestringName of the empty rule

Returns

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

Reports a rule whose alternatives cannot all be turned into tokens.

Parameters

$rulestringName of the unrealizable rule

Returns

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

Reports a rule with no alternative the generation plan admits.

Parameters

$rulestringName of the constrained rule

Returns

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

Reports a start rule that cannot satisfy the plan's non-empty requirement.

Parameters

$rulestringName of the start rule

Returns

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

Reports a plan that demanded output the grammar only produced as empty.

Parameters

$dialectstringDialect the generator was producing for

Returns

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

Reports that every derivation attempt failed to reach concrete SQL.

Parameters

$dialectstringDialect the generator was producing for

Returns

self Exception naming the dialect
Test cases 1
Calls 1

Test cases 28§

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

Dedicated tests 8
Other tests reaching this symbol 20

Relations§

Static calls 10