Skip to content

Commit 4bb3914

Browse files
Add BC layer for updated constructor types
1 parent db426a8 commit 4bb3914

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

ConstraintViolation.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@ class ConstraintViolation implements ConstraintViolationInterface
4949
* caused the violation
5050
* @param mixed $cause The cause of the violation
5151
*/
52-
public function __construct(string $message, ?string $messageTemplate, array $parameters, $root, ?string $propertyPath, $invalidValue, int $plural = null, $code = null, Constraint $constraint = null, $cause = null)
52+
public function __construct(?string $message, ?string $messageTemplate, array $parameters, $root, ?string $propertyPath, $invalidValue, int $plural = null, $code = null, Constraint $constraint = null, $cause = null)
5353
{
54+
if (null === $message) {
55+
@trigger_error(sprintf('Passing a null message when instantiating a "%s" is deprecated since Symfony 4.4.', __CLASS__), E_USER_DEPRECATED);
56+
$message = '';
57+
}
58+
5459
$this->message = $message;
5560
$this->messageTemplate = $messageTemplate;
5661
$this->parameters = $parameters;

Violation/ConstraintViolationBuilder.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,12 @@ class ConstraintViolationBuilder implements ConstraintViolationBuilderInterface
4747
/**
4848
* @param TranslatorInterface $translator
4949
*/
50-
public function __construct(ConstraintViolationList $violations, Constraint $constraint, string $message, array $parameters, $root, string $propertyPath, $invalidValue, $translator, string $translationDomain = null)
50+
public function __construct(ConstraintViolationList $violations, Constraint $constraint, ?string $message, array $parameters, $root, string $propertyPath, $invalidValue, $translator, string $translationDomain = null)
5151
{
52+
if (null === $message) {
53+
@trigger_error(sprintf('Passing a null message when instantiating a "%s" is deprecated since Symfony 4.4.', __CLASS__), E_USER_DEPRECATED);
54+
$message = '';
55+
}
5256
if (!$translator instanceof LegacyTranslatorInterface && !$translator instanceof TranslatorInterface) {
5357
throw new \TypeError(sprintf('Argument 8 passed to %s() must be an instance of %s, %s given.', __METHOD__, TranslatorInterface::class, \is_object($translator) ? \get_class($translator) : \gettype($translator)));
5458
}

0 commit comments

Comments
 (0)