classGenerationException
final class GenerationException
extends RuntimeException
@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.
$failure = new \SqlFaker\Generation\Exception\GenerationException('SQL generation failed');
$failure instanceof \RuntimeException // => true
$failure->getMessage() // => 'SQL generation failed'Methods§
public static function derivationLimitExceeded(): selfReports a derivation that ran past the plan's depth budget.
Returns
self Exception describing the exhausted budgetTest cases 1
Called from 5
- static-call SqlFaker\Generation\Derivation\Derivation::of() packages/sql-faker/src/Generation/Derivation/Derivation.php:80
- static-call SqlFaker\Generation\Derivation\Derivation::affordable() packages/sql-faker/src/Generation/Derivation/Derivation.php:144
- static-call SqlFaker\Generation\Derivation\Derivation::affordable() packages/sql-faker/src/Generation/Derivation/Derivation.php:152
- static-call SqlFaker\Generation\Derivation\Derivation::completable() packages/sql-faker/src/Generation/Derivation/Derivation.php:253
- static-call SqlFaker\Generation\Derivation\Derivation::affordableCompletion() packages/sql-faker/src/Generation/Derivation/Derivation.php:271
Calls 1
- new
selfline 37
public static function unknownRule(string $rule): selfReports a reference to a rule the grammar does not define.
Parameters
$rule | string | Name the production referred to |
Returns
self Exception naming the missing ruleTest cases 1
Called from 1
Calls 1
- new
selfline 50
public static function ruleHasNoAlternatives(string $rule): selfReports a rule that declares no alternatives to choose from.
Parameters
$rule | string | Name of the empty rule |
Returns
self Exception naming the empty ruleTest cases 1
Called from 1
Calls 1
- new
selfline 63
public static function noRealizableAlternative(string $rule): selfReports a rule whose alternatives cannot all be turned into tokens.
Parameters
$rule | string | Name of the unrealizable rule |
Returns
self Exception naming the unrealizable ruleTest cases 1
Called from 1
Calls 1
- new
selfline 76
public static function noAlternativeMatchingPlan(string $rule): selfReports a rule with no alternative the generation plan admits.
Parameters
$rule | string | Name of the constrained rule |
Returns
self Exception naming the constrained ruleTest cases 1
Called from 2
Calls 1
- new
selfline 89
public static function startRuleCannotProduceOutput(string $rule): selfReports a start rule that cannot satisfy the plan's non-empty requirement.
Parameters
$rule | string | Name of the start rule |
Returns
self Exception naming the start ruleCalls 1
- new
selfline 102
public static function planRequiresNonEmptyOutput(string $dialect): selfReports a plan that demanded output the grammar only produced as empty.
Parameters
$dialect | string | Dialect the generator was producing for |
Returns
self Exception naming the dialectTest cases 1
Called from 1
Calls 1
- new
selfline 117
public static function lexicalRealizationFailed(string $dialect): selfReports that every derivation attempt failed to reach concrete SQL.
Parameters
$dialect | string | Dialect the generator was producing for |
Returns
self Exception naming the dialectTest cases 1
Calls 1
- new
selfline 130
Test cases 31§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 8
GenerationExceptionTest::testDerivationLimitExceededReportsTheBudgetcallsGenerationExceptionTest::testLexicalRealizationFailedNamesTheDialectcallsGenerationExceptionTest::testNoAlternativeMatchingPlanNamesTheRulecallsGenerationExceptionTest::testNoRealizableAlternativeNamesTheRulecallsGenerationExceptionTest::testPlanRequiresNonEmptyOutputNamesTheDialectcallsGenerationExceptionTest::testRuleHasNoAlternativesNamesTheEmptyRulecallsGenerationExceptionTest::testStartRuleCannotProduceOutputNamesTheStartRulecallsGenerationExceptionTest::testUnknownRuleNamesTheMissingRulecalls
Other tests reaching this symbol 23
PlanBuilderTest::testBuildReportsAnUnknownRequestedRulecallsDerivationTest::testAffordableRejectsAnAlternativeThatCannotFitAfterTheRemaindercallsDerivationTest::testAffordableRejectsARemainderThatExceedsTheWholeBudgetcallsDerivationTest::testOfReportsAPlanNoAlternativeCanSatisfycallsDerivationTest::testOfReportsASymbolTheGrammarDeclaresNoRuleForcallsDerivationTest::testOfStillRejectsAnEntirelyForcedPlanWhoseDescendantCannotSatisfyNonEmptycallsDerivationTraceTestcallsTokenGeneratorTestcallsLexemeSequenceTestcallsCandidateResolverTestcallsGrammarCompilerTest::testCompileContradictoryProductionConditionsAreRejectedcallsSqlGeneratorTest::testGenerateClosesCoverageAfterARejectedEmptyLexicalResultcallsSqlGeneratorTest::testGenerateRejectsUnexpectedEmptyOutputWithoutRetryingcallsTerminalSequenceTestcallsGenerationContextTest::testReportsAnUnknownNonterminalWithoutTreatingItAsSqlTextcallsSqlGeneratorFactoryTestcallsMySqlProviderTestcallsGenerationContextTest::testReportsAnUnknownNonterminalWithoutTreatingItAsSqlTextcallsSqlGeneratorFactoryTestcallsPostgreSqlProviderTestcallsGenerationContextTest::testReportsAnUnknownNonterminalWithoutTreatingItAsSqlTextcallsSqlGeneratorFactoryTestcallsSqliteProviderTestcalls
Relations§
Static calls 11
- static-call SqlFaker\Generation\Derivation\Derivation::of() packages/sql-faker/src/Generation/Derivation/Derivation.php:80
- static-call SqlFaker\Generation\Derivation\Derivation::affordable() packages/sql-faker/src/Generation/Derivation/Derivation.php:144
- static-call SqlFaker\Generation\Derivation\Derivation::affordable() packages/sql-faker/src/Generation/Derivation/Derivation.php:152
- static-call SqlFaker\Generation\Derivation\Derivation::alternatives() packages/sql-faker/src/Generation/Derivation/Derivation.php:208
- static-call SqlFaker\Generation\Derivation\Derivation::alternatives() packages/sql-faker/src/Generation/Derivation/Derivation.php:210
- static-call SqlFaker\Generation\Derivation\Derivation::alternatives() packages/sql-faker/src/Generation/Derivation/Derivation.php:214
- static-call SqlFaker\Generation\Derivation\Derivation::alternatives() packages/sql-faker/src/Generation/Derivation/Derivation.php:227
- static-call SqlFaker\Generation\Derivation\Derivation::completable() packages/sql-faker/src/Generation/Derivation/Derivation.php:253
- static-call SqlFaker\Generation\Derivation\Derivation::affordableCompletion() packages/sql-faker/src/Generation/Derivation/Derivation.php:271
- static-call SqlFaker\Generation\Plan\Compilation\GrammarCompiler::compile() packages/sql-faker/src/Generation/Plan/Compilation/GrammarCompiler.php:50
- static-call SqlFaker\Generation\SqlGenerator::generate() packages/sql-faker/src/Generation/SqlGenerator.php:89