PlanExecutor
trait PlanExecutor
Execute compiled AttributePlans against validation data.
Architecture overview
Hypervel's validation uses compiled execution with a delegated subclass path:
-
Rules are compiled into AttributePlans by RuleCompiler — each rule becomes either an InlineCheck (fast, match-dispatched) or a DelegatedCheck (calls the existing validate*() method). Plans are cached worker-lifetime by RulePlanCache for Swoole performance.
-
Safe first-position exclusions are resolved before execution, and wildcard database-presence candidates are queried in ordered groups. Unknown values remain on the ordinary verifier path.
-
The exact Validator executes optimized plans through a branch-free loop. Subclasses use a Laravel-shaped loop over delegated checks so their validation and stopping hooks remain authoritative.
Maintenance notes
- Adding a new inline-eligible rule requires review in 4 places: CheckType (enum case + ruleName), RuleCompiler::tryInline(), executeInline() below, and canPreflightInline(). Omitting preflight support is correctness-safe but prevents presence batching across that rule.
- DelegatedChecks require zero changes — they call validate*() directly.
- executeInline() arms must match the exact behavior of their corresponding validate*() methods in ValidatesAttributes. When an upstream method changes, the inline arm must be updated to match.
Mixed into Validator so it can call existing helpers on ValidatesAttributes (sizeOf, isValidEmail, compareDates, etc.) and access validator state ($this->data, $this->rules, $this->currentRule, etc.).
Methods
Execute all compiled plans against the validation data.
Execute all-delegated plans for a Validator subclass.
Determine if a non-implicit check should be skipped.
Determine if an invalid upload should fail before rule execution.
Determine if an inline check is safe to repeat during presence preflight.
Execute an inline check against a value.
Details
at line 64
protected void
executeCompiledPlans(array $compiledPlans, array $preExcludedAttributes)
Execute all compiled plans against the validation data.
Per-check fresh reads of $value and $exists match validateAttribute()'s per-rule getValue() call.
at line 141
protected void
executeDelegatedPlans(array $compiledPlans)
Execute all-delegated plans for a Validator subclass.
at line 171
protected bool
shouldSkipNonImplicitCheck(AttributePlan $plan, mixed $value, bool $exists)
Determine if a non-implicit check should be skipped.
at line 181
protected bool
shouldFailInvalidUpload(string $attribute, mixed $value)
Determine if an invalid upload should fail before rule execution.
at line 191
protected bool
canPreflightInline(InlineCheck $check, mixed $value)
Determine if an inline check is safe to repeat during presence preflight.
at line 256
protected bool
executeInline(InlineCheck $check, mixed $value, string $attribute)
Execute an inline check against a value.
Dispatches via exhaustive match over CheckType — no default arm. Adding a CheckType case without a handler here fails PHPStan and throws UnhandledMatchError at runtime. Silent passes are impossible.
Each arm replicates the exact logic of the corresponding validate*() method in ValidatesAttributes, but without parameter parsing, attribute context lookups, or dynamic method dispatch.