diff --git a/.commitlintrc b/.commitlintrc index b32c85be16a..ea24b734af1 100644 --- a/.commitlintrc +++ b/.commitlintrc @@ -23,7 +23,7 @@ "parametervalidator", "serializer", "jsonschema", - "validation", + "validator", "state", "test" ] diff --git a/src/Validator/Exception/ValidationException.php b/src/Validator/Exception/ValidationException.php index cf9a777a84f..30b4bb312c0 100644 --- a/src/Validator/Exception/ValidationException.php +++ b/src/Validator/Exception/ValidationException.php @@ -102,7 +102,7 @@ class ValidationException extends RuntimeException implements ConstraintViolatio { private int $status = 422; protected ?string $errorTitle = null; - private array|ConstraintViolationListInterface $constraintViolationList = []; + private ConstraintViolationListInterface $constraintViolationList; public function __construct(string|ConstraintViolationListInterface $message = new ConstraintViolationList(), string|int|null $code = null, int|\Throwable|null $previous = null, \Throwable|string|null $errorTitle = null) { @@ -115,6 +115,8 @@ public function __construct(string|ConstraintViolationListInterface $message = n return; } + $this->constraintViolationList = new ConstraintViolationList(); + trigger_deprecation('api_platform/core', '5.0', \sprintf('The "%s" exception will have a "%s" first argument in 5.x.', self::class, ConstraintViolationListInterface::class)); parent::__construct($message ?: $this->__toString(), $code ?? 0, $previous); }