final class RulePlan
Public API: explicitly declared with @visibility public.

Conditions on a grammar subtree; nested conditions use grammar roles rather than global occurrence numbers.

Keep every matching production availabledoctest
$pattern = \SqlFaker\Generation\Plan\ProductionPattern::containing('SELECT');
    $plan = \SqlFaker\Generation\Plan\RulePlan::any()->allowing($pattern);
    $plan->pattern?->matches(['SELECT', 'expr']) // => true

Properties§

public ?ProductionPattern $pattern = null
public array<string, self> $rules = []
public array<string, LexemeConstraint> $lexemes = []
public non-empty-list<self>|null $items = null
public array<string, array<int, self>> $children = []

Methods§

public function __construct(
    public ?ProductionPattern $pattern = null,
    public array<string, self> $rules = [],
    public array<string, LexemeConstraint> $lexemes = [],
    public non-empty-list<self>|null $items = null,
    public array<string, array<int, self>> $children = [],
)

Parameters

$pattern?ProductionPattern
$rulesarray<string, self>Descendant scopes, with nearer scopes taking precedence
$lexemesarray<string, LexemeConstraint>Token domains inside this scope
$itemsnon-empty-list<self>|nullOrdered items of a directly recursive grammar list
$childrenarray<string, array<int, self>>Conditions on direct children, counted separately per production
public static function any(): self

Leaves every alternative available until conditions are added.

Returns

self
Test cases 32
Called from 1
Calls 1
public function allowing(ProductionPattern $pattern): self

Adds a condition on the root production without specifying descendants.

Parameters

Returns

self
Called from 1
Calls 2
public function withRule(string $rule, self $plan): self

Applies a plan whenever the named descendant rule is reached in this scope.

Parameters

$rulestring
$planself

Returns

self

Throws

InvalidArgumentException When the rule name is empty or its conditions conflict
Called from 1
Calls 2
public function withChild(string $rule, int $index, self $plan): self

Constrains a direct child, such as an operand, without counting unrelated subtrees.

Parameters

$rulestring
$indexint
$planself

Returns

self

Throws

InvalidArgumentException When the child selector or combined conditions are invalid
Calls 2
public function withLexeme(string $terminal, LexemeConstraint $constraint): self

Constrains every matching terminal in this scope, independently of sibling scopes.

Parameters

$terminalstring
$constraintLexemeConstraint

Returns

self

Throws

InvalidArgumentException When the terminal is empty or domains are disjoint
Calls 2
public function withItems(self $first, self ...$others): self

Specifies list items in output order while retaining compatible list productions. Each item constrains the non-recursive portion of one production of the list.

Parameters

$firstself
$othersself

Returns

self

Throws

InvalidArgumentException When two list conditions disagree
Calls 3
public function merge(self $other): self

Combines conditions at the same scope by intersection, never by silently replacing them.

Parameters

$otherself

Returns

self

Throws

InvalidArgumentException When lexical domains or list lengths conflict
Called from 1
Calls 4

Test cases 32§

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

Dedicated tests 9
Other tests reaching this symbol 23

Relations§

Instantiated in 1
Static calls 1
Method calls 1
Type declarations 3