class DataValidationCompiler

Constants

protected PRESENCE_RULES

Methods

__construct(DataClassRepository $dataClasses, Container $container, RuleDenormalizer $ruleDenormalizer)

Create a data validation compiler.

compile(ConstructionState $state)

Compile validation for one filled data graph.

compileCollection(ConstructionState $state, string $dataClass)

Compile validation for one filled root data collection.

void
compileNode(string $class, ConstructionState $state, ValidationPath $path, ValidationPath $structuralPath, ValidationAccumulator $accumulator, array $lifecycleDeclarations, bool $compileUnknownFields, bool $observed = true)

Compile one data node into the root rule graph.

void
compileDataIterable(DataProperty $property, string $dataClass, array $values, ConstructionState $state, ValidationPath $path, ValidationPath $structuralPath, ValidationAccumulator $accumulator, array $lifecycleDeclarations, bool $compileUnknownFields)

Compile nested rules for one data iterable.

void
compileDataIterableValues(string $dataClass, array $values, ConstructionState $state, ValidationPath $path, ValidationPath $structuralPath, ValidationAccumulator $accumulator, array $lifecycleDeclarations, bool $compileUnknownFields)

Compile one data iterable from its current structure path.

compileUniformDynamicIterable(string $dataClass, array $values, ConstructionState $state, ValidationPath $path, ValidationPath $structuralPath, array $lifecycleDeclarations, bool $compileUnknownFields)

Compile dynamic items at one wildcard path when their complete output matches.

array
propertyRules(DataProperty $property, ValidationPath $nodePath, ValidationPath $propertyPath, mixed $value, ConstructionState $state, bool $expectsArray, bool $inferredRequired)

Infer fixed presence and type rules for one property.

array
inferRules(DataProperty $property, bool $expectsArray, bool $hasPresenceRule = false)

Infer fixed presence and type rules for one property.

void
applyClassRules(DataClass $dataClass, ConstructionState $state, ValidationPath $path, ValidationPath $structuralPath, ValidationAccumulator $accumulator, bool $observed)

Apply class-owned rule replacements in PHP property-name space.

array
collapseTranslatedRulePaths(array $paths, ValidationAccumulator $accumulator)

Collapse concrete translations onto an existing authoritative wildcard rule.

void
applyClassMessagesAndAttributes(DataClass $dataClass, ConstructionState $state, ValidationPath $path, ValidationPath $structuralPath, ValidationAccumulator $accumulator, array $lifecycleDeclarations, bool $observed)

Apply class-owned messages and attribute labels in PHP property-name space.

array
callArrayLifecycleMethod(DataClass $dataClass, string $method, array $parameters = [])

Invoke one array-returning validation lifecycle method.

array
translateRulePaths(string $key, DataClass $dataClass, ConstructionState $state, ValidationPath $path, ValidationPath $structuralPath, bool $observed)

Translate a class rule key to its observed wire paths.

array
translateRuleSegments(array $segments, int $offset, DataClass $dataClass, ConstructionState $state, ValidationPath $path, ValidationPath $structuralPath, bool $observed)

Recursively translate class-rule segments through Data metadata.

appendUnmappedSegments(ValidationPath $path, array $segments, int $offset)

Append rule segments that no longer describe Data properties.

void
appendStructuralMarkers(ValidationAccumulator $accumulator, array $payload)

Append wildcard identity markers after every rule replacement is complete.

bool
hasDistinctRule(array $rules)

Determine if a rule list contains a distinct rule.

array
mergeRules(array $rules, array $additionalRules)

Merge rule lists without duplicating identical string rules.

bool
hasPresenceRule(array $rules)

Determine if a rule list explicitly controls field presence.

bool
usesDynamicRules(string $dataClass, ConstructionState $state)

Determine if item rules can differ across one collection.

string|null
primitiveRule(DataProperty $property)

Get one unambiguous primitive validation rule.

string|int
wireKey(DataProperty $property, ConstructionState $state, bool $observed)

Get the wire key selected during Fill or its canonical fallback.

void
recordAuxiliaryPath(DataProperty $property, ValidationPath $path, ValidationAccumulator $accumulator)

Record an exact field or opaque subtree excluded from rule compilation.

bool
canContainDescendants(DataProperty $property)

Determine if a skipped property can contain nested input.

bool
hasUnstructuredDescendants(DataProperty $property)

Determine if a validated property has no recursive schema.

bool
isUnstructuredObject(NamedType $type)

Determine if a named object type has no Data-owned child schema.

Details

at line 47
__construct(DataClassRepository $dataClasses, Container $container, RuleDenormalizer $ruleDenormalizer)

Create a data validation compiler.

Parameters

DataClassRepository $dataClasses
Container $container
RuleDenormalizer $ruleDenormalizer

at line 57
CompiledValidation compile(ConstructionState $state)

Compile validation for one filled data graph.

Parameters

ConstructionState $state

Return Value

CompiledValidation

at line 92
CompiledValidation compileCollection(ConstructionState $state, string $dataClass)

Compile validation for one filled root data collection.

Parameters

ConstructionState $state
string $dataClass

Return Value

CompiledValidation

at line 131
protected void compileNode(string $class, ConstructionState $state, ValidationPath $path, ValidationPath $structuralPath, ValidationAccumulator $accumulator, array $lifecycleDeclarations, bool $compileUnknownFields, bool $observed = true)

Compile one data node into the root rule graph.

Parameters

string $class
ConstructionState $state
ValidationPath $path
ValidationPath $structuralPath
ValidationAccumulator $accumulator
array $lifecycleDeclarations
bool $compileUnknownFields
bool $observed

Return Value

void

at line 292
protected void compileDataIterable(DataProperty $property, string $dataClass, array $values, ConstructionState $state, ValidationPath $path, ValidationPath $structuralPath, ValidationAccumulator $accumulator, array $lifecycleDeclarations, bool $compileUnknownFields)

Compile nested rules for one data iterable.

Parameters

DataProperty $property
string $dataClass
array $values
ConstructionState $state
ValidationPath $path
ValidationPath $structuralPath
ValidationAccumulator $accumulator
array $lifecycleDeclarations
bool $compileUnknownFields

Return Value

void

at line 329
protected void compileDataIterableValues(string $dataClass, array $values, ConstructionState $state, ValidationPath $path, ValidationPath $structuralPath, ValidationAccumulator $accumulator, array $lifecycleDeclarations, bool $compileUnknownFields)

Compile one data iterable from its current structure path.

Parameters

string $dataClass
array $values
ConstructionState $state
ValidationPath $path
ValidationPath $structuralPath
ValidationAccumulator $accumulator
array $lifecycleDeclarations
bool $compileUnknownFields

Return Value

void

at line 449
protected ValidationAccumulator|null compileUniformDynamicIterable(string $dataClass, array $values, ConstructionState $state, ValidationPath $path, ValidationPath $structuralPath, array $lifecycleDeclarations, bool $compileUnknownFields)

Compile dynamic items at one wildcard path when their complete output matches.

Parameters

string $dataClass
array $values
ConstructionState $state
ValidationPath $path
ValidationPath $structuralPath
array $lifecycleDeclarations
bool $compileUnknownFields

Return Value

ValidationAccumulator|null

at line 497
protected array propertyRules(DataProperty $property, ValidationPath $nodePath, ValidationPath $propertyPath, mixed $value, ConstructionState $state, bool $expectsArray, bool $inferredRequired)

Infer fixed presence and type rules for one property.

Parameters

DataProperty $property
ValidationPath $nodePath
ValidationPath $propertyPath
mixed $value
ConstructionState $state
bool $expectsArray
bool $inferredRequired

Return Value

array

at line 551
protected array inferRules(DataProperty $property, bool $expectsArray, bool $hasPresenceRule = false)

Infer fixed presence and type rules for one property.

Parameters

DataProperty $property
bool $expectsArray
bool $hasPresenceRule

Return Value

array

at line 579
protected void applyClassRules(DataClass $dataClass, ConstructionState $state, ValidationPath $path, ValidationPath $structuralPath, ValidationAccumulator $accumulator, bool $observed)

Apply class-owned rule replacements in PHP property-name space.

Parameters

DataClass $dataClass
ConstructionState $state
ValidationPath $path
ValidationPath $structuralPath
ValidationAccumulator $accumulator
bool $observed

Return Value

void

at line 672
protected array collapseTranslatedRulePaths(array $paths, ValidationAccumulator $accumulator)

Collapse concrete translations onto an existing authoritative wildcard rule.

Parameters

array $paths
ValidationAccumulator $accumulator

Return Value

array

at line 700
protected void applyClassMessagesAndAttributes(DataClass $dataClass, ConstructionState $state, ValidationPath $path, ValidationPath $structuralPath, ValidationAccumulator $accumulator, array $lifecycleDeclarations, bool $observed)

Apply class-owned messages and attribute labels in PHP property-name space.

Parameters

DataClass $dataClass
ConstructionState $state
ValidationPath $path
ValidationPath $structuralPath
ValidationAccumulator $accumulator
array $lifecycleDeclarations
bool $observed

Return Value

void

at line 782
protected array callArrayLifecycleMethod(DataClass $dataClass, string $method, array $parameters = [])

Invoke one array-returning validation lifecycle method.

Parameters

DataClass $dataClass
string $method
array $parameters

Return Value

array

at line 809
protected array translateRulePaths(string $key, DataClass $dataClass, ConstructionState $state, ValidationPath $path, ValidationPath $structuralPath, bool $observed)

Translate a class rule key to its observed wire paths.

Parameters

string $key
DataClass $dataClass
ConstructionState $state
ValidationPath $path
ValidationPath $structuralPath
bool $observed

Return Value

array

at line 834
protected array translateRuleSegments(array $segments, int $offset, DataClass $dataClass, ConstructionState $state, ValidationPath $path, ValidationPath $structuralPath, bool $observed)

Recursively translate class-rule segments through Data metadata.

Parameters

array $segments
int $offset
DataClass $dataClass
ConstructionState $state
ValidationPath $path
ValidationPath $structuralPath
bool $observed

Return Value

array

at line 1027
protected ValidationPath appendUnmappedSegments(ValidationPath $path, array $segments, int $offset)

Append rule segments that no longer describe Data properties.

Parameters

ValidationPath $path
array $segments
int $offset

Return Value

ValidationPath

at line 1044
protected void appendStructuralMarkers(ValidationAccumulator $accumulator, array $payload)

Append wildcard identity markers after every rule replacement is complete.

Parameters

ValidationAccumulator $accumulator
array $payload

Return Value

void

at line 1122
protected bool hasDistinctRule(array $rules)

Determine if a rule list contains a distinct rule.

Parameters

array $rules

Return Value

bool

at line 1146
protected array mergeRules(array $rules, array $additionalRules)

Merge rule lists without duplicating identical string rules.

Parameters

array $rules
array $additionalRules

Return Value

array

at line 1164
protected bool hasPresenceRule(array $rules)

Determine if a rule list explicitly controls field presence.

Parameters

array $rules

Return Value

bool

at line 1190
protected bool usesDynamicRules(string $dataClass, ConstructionState $state)

Determine if item rules can differ across one collection.

Parameters

string $dataClass
ConstructionState $state

Return Value

bool

at line 1202
protected string|null primitiveRule(DataProperty $property)

Get one unambiguous primitive validation rule.

Parameters

DataProperty $property

Return Value

string|null

at line 1227
protected string|int wireKey(DataProperty $property, ConstructionState $state, bool $observed)

Get the wire key selected during Fill or its canonical fallback.

Parameters

DataProperty $property
ConstructionState $state
bool $observed

Return Value

string|int

at line 1244
protected void recordAuxiliaryPath(DataProperty $property, ValidationPath $path, ValidationAccumulator $accumulator)

Record an exact field or opaque subtree excluded from rule compilation.

Parameters

DataProperty $property
ValidationPath $path
ValidationAccumulator $accumulator

Return Value

void

at line 1259
protected bool canContainDescendants(DataProperty $property)

Determine if a skipped property can contain nested input.

Parameters

DataProperty $property

Return Value

bool

at line 1280
protected bool hasUnstructuredDescendants(DataProperty $property)

Determine if a validated property has no recursive schema.

Parameters

DataProperty $property

Return Value

bool

at line 1298
protected bool isUnstructuredObject(NamedType $type)

Determine if a named object type has no Data-owned child schema.

Parameters

NamedType $type

Return Value

bool