Skip to content

ValidatorDeclarationApplier

Builds the validators a compiled validator config declares and attaches them to a validation manager.

This is the code that used to be the compiled artifact itself: new X(); ->initialize(...); ->addChild(...), emitted as text and executed in the caller’s scope. It is here instead, so the artifact is data — a poisoned config cache entry can then only describe wrong validators, not run code — and so registration can be tested directly rather than by executing a generated string.

final class ValidatorDeclarationApplier

Since4.0.0
SourceValidator/Compiler/Runtime/ValidatorDeclarationApplier.php
MethodDescription
apply(mixed $declaration, ValidationManager $validationManager, string $method, Context $context, string $sourceRef): voidRegister the declared validators for one request method.

public static function apply(mixed $declaration, ValidationManager $validationManager, string $method, Context $context, string $sourceRef): void

Register the declared validators for one request method.

The validator config file, for diagnostics.

ParameterTypeDescription
$declarationmixedThe value the compiled validator config returned.
$validationManagerValidationManagerThe manager to register against.
$methodstringThe request method token the declaration is matched against (lowercase, as the compiler wrote it).
$contextContextThe context validators are initialized with.
$sourceRefstringThe validator config file, for diagnostics.
ThrowsWhen
ConfigurationExceptionIf the declaration is not the shape the compiler produces.