classLexemeConstraint
final class LexemeConstraint
Public API: explicitly declared with
@visibility public.A constructive set of token spellings, independent of their position in a statement.
$names = \SqlFaker\Generation\Plan\LexemeConstraint::oneOf('users', 'orders');
$names->accepts('users') // => true
$names->accepts('products') // => falseMethods§
public function __construct(
private list<string> $values,
private int $minimum = 0,
private int $maximum = PHP_INT_MAX,
)An empty spelling set selects the integer interval instead.
Parameters
$values | list<string> | |
$minimum | int | |
$maximum | int |
Throws
InvalidArgumentException When the integer interval is empty or negativeCalls 1
- new
InvalidArgumentExceptionline 30
public static function oneOf(string $first, string ...$others): selfKeeps every supplied spelling reachable, including quoted names and literals.
Parameters
$first | string | |
$others | string |
Returns
selfTest cases 21
PlanBuilderTest::testBuildFreezesScopedValuesAndDefaultsWhenChoiceBytesRunOutcallsGrammarCompilerTest::testRuleDoesNotShareACompiledSubtreeBetweenDifferentLexicalScopescallsPreparedGrammarTest::testRestoreRetainsTheLexicalScopeOfEachSelectedProductioncallsScopedGenerationTest::testConstraintResolvesNearestAncestorWithoutAffectingOtherTokenscallsScopedGenerationTest::testLexicalPlanExplicitLexemesCannotSilentlyOverrideScopedConditionscallsScopedGenerationTest::testLexicalPlanPreservesLegacySpellingsWhenARewriterRenamesTokenscallsScopedGenerationTest::testLexicalPlanRewrittenAndSiblingTokensKeepTheirOwnDomainscallsScopeTest::testEnterNearerScopesOverrideDefaultsWithoutLeakingToSiblingscallsScopeTest::testEnterOverridesOnlyDeclaredRolesAndCanonicalizesIndependentDeclarationOrdercallsLexemeConstraintTest::testIntegersBoundsAndFiniteSetsIntersectWithoutSamplingcallsLexemeConstraintTest::testIntersectIsIndependentOfWhichSideHoldsTheFiniteSetcallsLexemeConstraintTest::testOneOfChoicesRemainReachableAndIntersectionRemovesOnlyForbiddenSpellingscallsLexemeConstraintTest::testOneOfDeduplicatesValuesWithoutLeavingChoiceIndexGapscallsRulePlanTest::testAllowingRefinementsIntersectAndLeaveTheOriginalPlanIntactcallsRulePlanTest::testMergeCombinesNestedRulesAndPreservesIndependentBindingscallsRulePlanTest::testMergeIntersectsCorrespondingListItemscallsRulePlanTest::testWithItemsAcceptsNamedArgumentsAndKeepsEveryItemInOrdercallsRulePlanTest::testWithItemsRetainsHeterogeneousOutputOrdercallsRulePlanTest::testWithLexemeIntersectsDomainsWithoutChangingOtherTokenscallsMySqlProviderTest::providerScopedInsertPlancallsPostgreSqlProviderTest::providerScopedInsertPlancalls
public static function integers(int $minimum, int $maximum): selfBounds an unsigned integer token; signs remain part of the surrounding grammar.
Parameters
$minimum | int | |
$maximum | int |
Returns
selfThrows
InvalidArgumentException When the interval is empty or negativeTest cases 7
LexemeConstraintTest::testAcceptsUsesLexicalSpellingsRatherThanNumericCoercioncallsLexemeConstraintTest::testChooseRetainsTheWholeIntegerIntervalIncludingItsBoundscallsLexemeConstraintTest::testIntegersBoundsAndFiniteSetsIntersectWithoutSamplingcallsLexemeConstraintTest::testIntegersSupportsSingletonIntervalsIncludingZerocallsLexemeConstraintTest::testIntersectIsIndependentOfWhichSideHoldsTheFiniteSetcallsMySqlProviderTest::providerScopedInsertPlancallsPostgreSqlProviderTest::providerScopedInsertPlancalls
Called from 1
Calls 1
- new
selfline 48
public function choose(Closure(positive-int): int $choose): stringParameters
$choose | Closure(positive-int): int |
Returns
stringTest cases 1
Calls 3
- function-call
countline 57 - method-call IntegerDomain::choose() line 59
- new IntegerDomain line 59
public function accepts(string $value): boolChecks an exact spelling without coercing quoted strings into numbers.
Parameters
$value | string |
Returns
boolCalled from 1
Calls 4
- function-call
in_arrayline 68 - new IntegerDomain line 70
- function-call
strlenline 71 - method-call IntegerDomain::match() line 71
public function intersect(self $other): selfIntersects conditions constructively, without generating and rejecting samples.
Parameters
$other | self |
Returns
selfThrows
InvalidArgumentException When the conditions have no common spellingCalls 9
- function-call
array_valuesline 81 - function-call
array_filterline 81 - method-call LexemeConstraint::accepts() line 81
- method-call
self::accepts()line 81 - new
InvalidArgumentExceptionline 83 - new
selfline 85 - static-call LexemeConstraint::integers() line 87
- function-call
maxline 87 - function-call
minline 87
Private surface 3§
Implementation details, listed for orientation only.
private list<string> $valuesprivate int $minimum = 0private int $maximum = PHP_INT_MAXTest cases 25§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 8
LexemeConstraintTest::testAcceptsUsesLexicalSpellingsRatherThanNumericCoercioncallsLexemeConstraintTest::testChooseDefaultIntegerDomainIncludesZerocallsLexemeConstraintTest::testChooseRetainsTheWholeIntegerIntervalIncludingItsBoundscallsLexemeConstraintTest::testIntegersBoundsAndFiniteSetsIntersectWithoutSamplingcallsLexemeConstraintTest::testIntegersSupportsSingletonIntervalsIncludingZerocallsLexemeConstraintTest::testIntersectIsIndependentOfWhichSideHoldsTheFiniteSetcallsLexemeConstraintTest::testOneOfChoicesRemainReachableAndIntersectionRemovesOnlyForbiddenSpellingscallsLexemeConstraintTest::testOneOfDeduplicatesValuesWithoutLeavingChoiceIndexGapscalls
Other tests reaching this symbol 17
PlanBuilderTest::testBuildFreezesScopedValuesAndDefaultsWhenChoiceBytesRunOutcallsGrammarCompilerTest::testRuleDoesNotShareACompiledSubtreeBetweenDifferentLexicalScopescallsPreparedGrammarTest::testRestoreRetainsTheLexicalScopeOfEachSelectedProductioncallsScopedGenerationTest::testConstraintResolvesNearestAncestorWithoutAffectingOtherTokenscallsScopedGenerationTest::testLexicalPlanExplicitLexemesCannotSilentlyOverrideScopedConditionscallsScopedGenerationTest::testLexicalPlanPreservesLegacySpellingsWhenARewriterRenamesTokenscallsScopedGenerationTest::testLexicalPlanRewrittenAndSiblingTokensKeepTheirOwnDomainscallsScopeTest::testEnterNearerScopesOverrideDefaultsWithoutLeakingToSiblingscallsScopeTest::testEnterOverridesOnlyDeclaredRolesAndCanonicalizesIndependentDeclarationOrdercallsRulePlanTest::testAllowingRefinementsIntersectAndLeaveTheOriginalPlanIntactcallsRulePlanTest::testMergeCombinesNestedRulesAndPreservesIndependentBindingscallsRulePlanTest::testMergeIntersectsCorrespondingListItemscallsRulePlanTest::testWithItemsAcceptsNamedArgumentsAndKeepsEveryItemInOrdercallsRulePlanTest::testWithItemsRetainsHeterogeneousOutputOrdercallsRulePlanTest::testWithLexemeIntersectsDomainsWithoutChangingOtherTokenscallsMySqlProviderTest::providerScopedInsertPlancallsPostgreSqlProviderTest::providerScopedInsertPlancalls