final class LegacyValidationRuleParser extends ValidationRuleParser

Parser with the original O(n²) wildcard expansion for baseline benchmarks.

Uses Arr::dot() + regex matching instead of the tree-walk approach, reproducing the pre-optimization wildcard expansion behavior.

Properties

array $implicitAttributes

The implicit attributes.

from  ValidationRuleParser

Methods

__construct(array $data)

Create a new validation rule parser.

explode(array $rules)

Parse the human-friendly rules into a full rules array for the validator.

array
explodeRules(array $rules)

Explode the rules into an array of explicit rules.

array
explodeExplicitRule(mixed $rule, string $attribute)

Explode the explicit rule into an array if necessary.

mixed
prepareRule(mixed $rule, string $attribute)

Prepare the given rule for the Validator.

static bool
ruleReducesToString(mixed $rule)

Determine if the parser reduces a rule object to its string form.

array
explodeWildcardRules(array $results, string $attribute, array|object|string $rules)

Original O(n²) wildcard expansion via Arr::dot() + regex.

array
explodeWildcardRulesCompilable(array $results, string $attribute, array|object|string $rules)

Explode wildcard rules that contain compilable rules.

bool
containsCompilableRules(array $rules)

Determine if a rules array contains any CompilableRules at any nesting level.

array
mergeRules(array $results, array|object|string $attribute, array|object|string $rules = [])

Merge additional rules into a given attribute(s).

array
mergeRulesForAttribute(array $results, string $attribute, array|object|string $rules)

Merge additional rules into a given attribute.

static array
parse(array|object|string $rule)

Extract the rule name and parameters from a rule.

static array
parseArrayRule(array $rule)

Parse an array based rule.

static array
parseStringRule(string|Stringable $rule)

Parse a string based rule.

static array
parseParameters(string $rule, string $parameter)

Parse a parameter list.

static bool
ruleIsRegex(string $rule)

Determine if the rule is a regular expression.

static string
normalizeRule(string $rule)

Normalizes a rule so that we can accept short types.

static bool
looksLikeDateFieldReference(mixed $argument)

Determine if a rule argument names a field rather than stating a date literal.

static array
filterConditionalRules(array $rules, array $data = [])

Expand the conditional rules in the given array of rules.

static void
flushState()

Flush all static state.

Details

__construct(array $data)

Create a new validation rule parser.

Parameters

array $data

the data being validated

stdClass explode(array $rules)

Parse the human-friendly rules into a full rules array for the validator.

Parameters

array $rules

Return Value

stdClass

protected array explodeRules(array $rules)

Explode the rules into an array of explicit rules.

Parameters

array $rules

Return Value

array

protected array explodeExplicitRule(mixed $rule, string $attribute)

Explode the explicit rule into an array if necessary.

Parameters

mixed $rule
string $attribute

Return Value

array

in ValidationRuleParser at line 114
protected mixed prepareRule(mixed $rule, string $attribute)

Prepare the given rule for the Validator.

Parameters

mixed $rule
string $attribute

Return Value

mixed

in ValidationRuleParser at line 150
static bool ruleReducesToString(mixed $rule)

Determine if the parser reduces a rule object to its string form.

Parameters

mixed $rule

Return Value

bool

at line 468
protected array explodeWildcardRules(array $results, string $attribute, array|object|string $rules)

Original O(n²) wildcard expansion via Arr::dot() + regex.

Parameters

array $results
string $attribute
array|object|string $rules

Return Value

array

in ValidationRuleParser at line 209
protected array explodeWildcardRulesCompilable(array $results, string $attribute, array|object|string $rules)

Explode wildcard rules that contain compilable rules.

Compiled rules receive the flattened data, which the tree walk does not build.

Parameters

array $results
string $attribute
array|object|string $rules

Return Value

array

in ValidationRuleParser at line 321
protected bool containsCompilableRules(array $rules)

Determine if a rules array contains any CompilableRules at any nesting level.

Checks both top-level elements and elements inside nested arrays, so mixed rule arrays like ['nullable', Rule::forEach(...)] are detected.

Parameters

array $rules

Return Value

bool

in ValidationRuleParser at line 339
array mergeRules(array $results, array|object|string $attribute, array|object|string $rules = [])

Merge additional rules into a given attribute(s).

Parameters

array $results
array|object|string $attribute
array|object|string $rules

Return Value

array

in ValidationRuleParser at line 361
protected array mergeRulesForAttribute(array $results, string $attribute, array|object|string $rules)

Merge additional rules into a given attribute.

Parameters

array $results
string $attribute
array|object|string $rules

Return Value

array

in ValidationRuleParser at line 384
static array parse(array|object|string $rule)

Extract the rule name and parameters from a rule.

Parameters

array|object|string $rule

Return Value

array

in ValidationRuleParser at line 419
static protected array parseArrayRule(array $rule)

Parse an array based rule.

Parameters

array $rule

Return Value

array

in ValidationRuleParser at line 427
static protected array parseStringRule(string|Stringable $rule)

Parse a string based rule.

Parameters

string|Stringable $rule

Return Value

array

in ValidationRuleParser at line 447
static protected array parseParameters(string $rule, string $parameter)

Parse a parameter list.

Parameters

string $rule
string $parameter

Return Value

array

in ValidationRuleParser at line 456
static protected bool ruleIsRegex(string $rule)

Determine if the rule is a regular expression.

Parameters

string $rule

Return Value

bool

in ValidationRuleParser at line 464
static protected string normalizeRule(string $rule)

Normalizes a rule so that we can accept short types.

Parameters

string $rule

Return Value

string

in ValidationRuleParser at line 481
static bool looksLikeDateFieldReference(mixed $argument)

Determine if a rule argument names a field rather than stating a date literal.

Behavioral callers must attempt literal parsing first. Compiler callers may conservatively delegate because false positives only select the full path.

Parameters

mixed $argument

Return Value

bool

in ValidationRuleParser at line 502
static array filterConditionalRules(array $rules, array $data = [])

Expand the conditional rules in the given array of rules.

Parameters

array $rules
array $data

Return Value

array

in ValidationRuleParser at line 530
static void flushState()

Flush all static state.

Return Value

void