LegacyValidationRuleParser
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
Parse the human-friendly rules into a full rules array for the validator.
Explode the rules into an array of explicit rules.
Explode the explicit rule into an array if necessary.
Prepare the given rule for the Validator.
Determine if the parser reduces a rule object to its string form.
Original O(n²) wildcard expansion via Arr::dot() + regex.
Explode wildcard rules that contain compilable rules.
Determine if a rules array contains any CompilableRules at any nesting level.
Merge additional rules into a given attribute(s).
Merge additional rules into a given attribute.
Extract the rule name and parameters from a rule.
Parse a parameter list.
Determine if the rule is a regular expression.
Normalizes a rule so that we can accept short types.
Determine if a rule argument names a field rather than stating a date literal.
Expand the conditional rules in the given array of rules.
Details
in
ValidationRuleParser at line 43
__construct(array $data)
Create a new validation rule parser.
in
ValidationRuleParser at line 51
stdClass
explode(array $rules)
Parse the human-friendly rules into a full rules array for the validator.
in
ValidationRuleParser at line 66
protected array
explodeRules(array $rules)
Explode the rules into an array of explicit rules.
in
ValidationRuleParser at line 85
protected array
explodeExplicitRule(mixed $rule, string $attribute)
Explode the explicit rule into an array if necessary.
in
ValidationRuleParser at line 116
protected mixed
prepareRule(mixed $rule, string $attribute)
Prepare the given rule for the Validator.
in
ValidationRuleParser at line 152
static bool
ruleReducesToString(mixed $rule)
Determine if the parser reduces a rule object to its string form.
at line 469
protected array
explodeWildcardRules(array $results, string $attribute, array|object|string $rules)
Original O(n²) wildcard expansion via Arr::dot() + regex.
in
ValidationRuleParser at line 212
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.
in
ValidationRuleParser at line 324
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.
in
ValidationRuleParser at line 342
array
mergeRules(array $results, array|object|string $attribute, array|object|string $rules = [])
Merge additional rules into a given attribute(s).
in
ValidationRuleParser at line 364
protected array
mergeRulesForAttribute(array $results, string $attribute, array|object|string $rules)
Merge additional rules into a given attribute.
in
ValidationRuleParser at line 387
static array
parse(array|object|string $rule)
Extract the rule name and parameters from a rule.
in
ValidationRuleParser at line 426
static protected array
parseArrayRule(array $rule)
Parse an array based rule.
in
ValidationRuleParser at line 434
static protected array
parseStringRule(string|Stringable $rule)
Parse a string based rule.
in
ValidationRuleParser at line 454
static protected array
parseParameters(string $rule, string $parameter)
Parse a parameter list.
in
ValidationRuleParser at line 463
static protected bool
ruleIsRegex(string $rule)
Determine if the rule is a regular expression.
in
ValidationRuleParser at line 471
static protected string
normalizeRule(string $rule)
Normalizes a rule so that we can accept short types.
in
ValidationRuleParser at line 488
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.
in
ValidationRuleParser at line 509
static array
filterConditionalRules(array $rules, array $data = [])
Expand the conditional rules in the given array of rules.
in
ValidationRuleParser at line 537
static void
flushState()
Flush all static state.