Skip to content

ValidationReport

ValidationReport stores the result of a validation run.

class ValidationReport implements IValidationReportQuery, ResetInterface

ImplementsIValidationReportQuery, ResetInterface
Since1.0.0
SourceValidator/ValidationReport.php
MethodDescription
addArgumentResult(ValidationArgument $argument, int $result, Validator $validator = null): voidAdds a intermediate result of an validator for the given argument
addIncident(ValidationIncident $incident): voidAdds an incident to the validation result.
[`byArgument(ValidationArgumentstring
[`byErrorName(stringarray<int, string> $name): IValidationReportQuery`](#byerrorname)
byMaxSeverity(int $maxSeverity): IValidationReportQueryReturns a new IValidationReportQuery which contains only the incidents of the given severity or lower (and the other existing filter rules).
byMinSeverity(int $minSeverity): IValidationReportQueryReturns a new IValidationReportQuery which contains only the incidents of the given severity or higher (and the other existing filter rules).
[`byValidator(stringarray<int, string> $name): IValidationReportQuery`](#byvalidator)
count(): intGet the number of incidents matching the currently defined filter rules.
createQuery(): IValidationReportQueryCreate a new ValidationReportQuery for this report.
getArgumentResults(): array<string, array<int, array{argument: ValidationArgument, severity: int, validator: ?Validator}>>Retrieve the internal array (indexed by argument hash) of argument/severity/validator tuples.
getArguments(): array<int, ValidationArgument>Retrieves all ValidationArgument objects in this report.
getAuthoritativeArgumentSeverity(ValidationArgument $argument, string $validatorName = null): ?intWill return the highest error severity for an argument.
[`getDependTokens(): array<intstring, mixed>`](#getdependtokens)
getErrorMessages(): array<int, string>Retrieves all error messages in this report.
getErrorMessagesWithFields(): array<int, array{message: string, errors: array<int, string>}>Retrieves all error messages together with the fields that caused them.
getErrors(): array<int, ValidationError>Retrieves all ValidationError objects in this report.
getFailedArguments(string $source = null): array<string, ValidationArgument>Returns all arguments which failed in the validation.
getIncidents(): array<int, ValidationIncident>Returns all incidents which happened during the execution of the validation.
getResult(): ?intRetrieves the highest validation result code in this report.
getSucceededArguments(string $source = null): array<string, ValidationArgument>Returns all arguments which validated successfully.
has(): boolCheck if there are any incidents matching the currently defined filter rules.
hasDependToken(string $token): boolCheck whether the given depend token was provided by the validation run.
hasIncidents(): boolChecks if any incidents occurred Returns all arguments which succeeded in the validation.
isArgumentFailed(ValidationArgument $argument): boolChecks whether an argument has failed in any validator.
isArgumentValidated(ValidationArgument $argument): boolChecks whether an argument has been processed by a validator (this includes arguments which were skipped because their value was not set and the validator was not required)
reset(): voidReturns the report to its initial state for reuse across requests.
[`setDependTokens(array<intstring, mixed> $dependTokens = []): void`](#setdependtokens)
setResult(int $result): voidSets the validation result

public function addArgumentResult(ValidationArgument $argument, int $result, Validator $validator = null): void

Adds a intermediate result of an validator for the given argument

The validator (if the error was cause inside a validator).

ParameterTypeDescription
$argumentValidationArgumentThe argument
$resultintThe arguments result.
$validatorValidatorThe validator (if the error was cause inside a validator).

public function addIncident(ValidationIncident $incident): void

Adds an incident to the validation result.

The incident.

ParameterTypeDescription
$incidentValidationIncidentThe incident.

public function byArgument(ValidationArgument|string|array<int, ValidationArgument|string> $argument): IValidationReportQuery

Returns a new IValidationReportQuery which returns only the incidents for the given argument (and the other existing filter rules).

The argument instance, or a parameter name, or an array of these elements.

ParameterTypeDescription
$argumentValidationArgument`string

Returns IValidationReportQuery

public function byErrorName(string|array<int, string> $name): IValidationReportQuery

Returns a new IValidationReportQuery which contains only the incidents for the given error name (and the other existing filter rules).

The name of the error, or an array of names.

ParameterTypeDescription
$name`string“array<int, string>`

Returns IValidationReportQuery

public function byMaxSeverity(int $maxSeverity): IValidationReportQuery

Returns a new IValidationReportQuery which contains only the incidents of the given severity or lower (and the other existing filter rules).

The maximum severity.

ParameterTypeDescription
$maxSeverityintThe maximum severity.

Returns IValidationReportQuery

public function byMinSeverity(int $minSeverity): IValidationReportQuery

Returns a new IValidationReportQuery which contains only the incidents of the given severity or higher (and the other existing filter rules).

The minimum severity.

ParameterTypeDescription
$minSeverityintThe minimum severity.

Returns IValidationReportQuery

public function byValidator(string|array<int, string> $name): IValidationReportQuery

Returns a new IValidationReportQuery which contains only the incidents for the given validator (and the other existing filter rules).

The name of the validator, or an array of names.

ParameterTypeDescription
$name`string“array<int, string>`

Returns IValidationReportQuery

public function count(): int

Get the number of incidents matching the currently defined filter rules.

Returns int — The number of incidents in this report.

public function createQuery(): IValidationReportQuery

Create a new ValidationReportQuery for this report.

Returns IValidationReportQuery

public function getArgumentResults(): array<string, array<int, array{argument: ValidationArgument, severity: int, validator: ?Validator}>>

Retrieve the internal array (indexed by argument hash) of argument/severity/validator tuples.

This method exposes an internal data structure that may change at any time. You shouldn’t have to use this method. Don’t even think about using it to harm cute little animals, or you shall suffer the wrath of an angry god.

Returns array``<``string``, ``array``<``int``, ``array{argument: ValidationArgument, severity: int, validator: ?Validator}``>``> — An array of argument result info arrays.

public function getArguments(): array<int, ValidationArgument>

Retrieves all ValidationArgument objects in this report.

Returns array``<``int``, ValidationArgument> — An array of ValidationArgument objects.

public function getAuthoritativeArgumentSeverity(ValidationArgument $argument, string $validatorName = null): ?int

Will return the highest error severity for an argument.

Optional name of a specific validator to get a result for.

ParameterTypeDescription
$argumentValidationArgumentThe argument.
$validatorNamestringOptional name of a specific validator to get a result for.

Returns ?``int — The error severity.

public function getDependTokens(): array<int|string, mixed>

Check whether the given depend token was provided by the validation run.

Returns array``<``int``|``string``, ``mixed``> — All provided depend tokens.

public function getErrorMessages(): array<int, string>

Retrieves all error messages in this report.

Returns array``<``int``, ``string``> — An array of message strings.

public function getErrorMessagesWithFields(): array<int, array{message: string, errors: array<int, string>}>

Retrieves all error messages together with the fields that caused them.

Returns the same array(‘message’ => string, ‘errors’ => array) structure as the deprecated ValidationManager::getErrorMessages(), but as a non-deprecated accessor. Callers migrating off the deprecated method can use getReport()->getErrorMessagesWithFields() to keep the field-annotated shape.

Returns array``<``int``, ``array{message: string, errors: array<int, string>}``> — An array of array(‘message’ => string, ‘errors’ => array).

public function getErrors(): array<int, ValidationError>

Retrieves all ValidationError objects in this report.

Returns array``<``int``, ValidationError> — An array of ValidationError objects.

public function getFailedArguments(string $source = null): array<string, ValidationArgument>

Returns all arguments which failed in the validation.

Optional source name to limit the list of arguments to.

ParameterTypeDescription
$sourcestringOptional source name to limit the list of arguments to.

Returns array``<``string``, ValidationArgument> — An array of ValidationArgument objects.

public function getIncidents(): array<int, ValidationIncident>

Returns all incidents which happened during the execution of the validation.

Returns array``<``int``, ValidationIncident> — The incidents.

public function getResult(): ?int

Retrieves the highest validation result code in this report.

Returns ?``int — An Validator::* severity constant, or null if there is no result. Please remember to do a strict === comparison if you are comparing against Validator::SUCCESS.

public function getSucceededArguments(string $source = null): array<string, ValidationArgument>

Returns all arguments which validated successfully.

Optional source name to limit the list of arguments to.

ParameterTypeDescription
$sourcestringOptional source name to limit the list of arguments to.

Returns array``<``string``, ValidationArgument> — An array of ValidationArgument objects.

public function has(): bool

Check if there are any incidents matching the currently defined filter rules.

Returns bool — Whether or not any incidents exist in this report.

public function hasDependToken(string $token): bool

Check whether the given depend token was provided by the validation run.

Name of depend token suspected to have been provided.

ParameterTypeDescription
$tokenstringName of depend token suspected to have been provided.

Returns bool — True if depend token was provided.

public function hasIncidents(): bool

Checks if any incidents occurred Returns all arguments which succeeded in the validation.

Includes arguments which were not processed (happens when the argument is “not set” and the validator is not required)

Returns bool — The result.

public function isArgumentFailed(ValidationArgument $argument): bool

Checks whether an argument has failed in any validator.

The argument.

ParameterTypeDescription
$argumentValidationArgumentThe argument.

Returns bool — Whether the validating that argument has failed.

public function isArgumentValidated(ValidationArgument $argument): bool

Checks whether an argument has been processed by a validator (this includes arguments which were skipped because their value was not set and the validator was not required)

The argument.

ParameterTypeDescription
$argumentValidationArgumentThe argument.

Returns bool — Whether the argument was validated.

public function reset(): void

Returns the report to its initial state for reuse across requests.

Clears the per-argument results, the incidents and the provided dependency tokens, and puts the cached overall result back to null so that the next query recomputes it from scratch.

public function setDependTokens(array<int|string, mixed> $dependTokens = []): void

Sets dependency tokens provided by executed validators onto the result.

The depend tokens of the DependencyManager.

ParameterTypeDescription
$dependTokens`array<int“string, mixed>`

public function setResult(int $result): void

Sets the validation result

The new validation result

ParameterTypeDescription
$resultintThe new validation result