diff --git a/UPGRADE-6.1.md b/UPGRADE-6.1.md index 514c18c5b319d..d48aca725b3f6 100644 --- a/UPGRADE-6.1.md +++ b/UPGRADE-6.1.md @@ -33,3 +33,5 @@ Validator * Deprecate `Constraint::$errorNames`, use `Constraint::ERROR_NAMES` instead * Deprecate constraint `ExpressionLanguageSyntax`, use `ExpressionSyntax` instead + * Implementing the `ConstraintViolationInterface` or `ConstraintViolationListInterface` + without implementing the `__toString()` method is deprecated diff --git a/src/Symfony/Component/Validator/CHANGELOG.md b/src/Symfony/Component/Validator/CHANGELOG.md index bdb42bcd213ba..1b395fc45eed4 100644 --- a/src/Symfony/Component/Validator/CHANGELOG.md +++ b/src/Symfony/Component/Validator/CHANGELOG.md @@ -6,6 +6,7 @@ CHANGELOG * Deprecate `Constraint::$errorNames`, use `Constraint::ERROR_NAMES` instead * Deprecate constraint `ExpressionLanguageSyntax`, use `ExpressionSyntax` instead + * Add method `__toString()` to `ConstraintViolationInterface` & `ConstraintViolationListInterface` 6.0 --- diff --git a/src/Symfony/Component/Validator/ConstraintViolation.php b/src/Symfony/Component/Validator/ConstraintViolation.php index 713248c0f915a..4fb8b0a7cac77 100644 --- a/src/Symfony/Component/Validator/ConstraintViolation.php +++ b/src/Symfony/Component/Validator/ConstraintViolation.php @@ -64,7 +64,7 @@ public function __construct(string|\Stringable $message, ?string $messageTemplat } /** - * Converts the violation into a string for debugging purposes. + * {@inheritdoc} */ public function __toString(): string { diff --git a/src/Symfony/Component/Validator/ConstraintViolationInterface.php b/src/Symfony/Component/Validator/ConstraintViolationInterface.php index 927fa66f0eb40..6fc584116eaad 100644 --- a/src/Symfony/Component/Validator/ConstraintViolationInterface.php +++ b/src/Symfony/Component/Validator/ConstraintViolationInterface.php @@ -30,6 +30,8 @@ * element is still the person, but the property path is "address.street". * * @author Bernhard Schussek + * + * @method string __toString() Converts the violation into a string for debugging purposes. Not implementing it is deprecated since Symfony 6.1. */ interface ConstraintViolationInterface { diff --git a/src/Symfony/Component/Validator/ConstraintViolationList.php b/src/Symfony/Component/Validator/ConstraintViolationList.php index a91f0413da27a..a0b157ea0034c 100644 --- a/src/Symfony/Component/Validator/ConstraintViolationList.php +++ b/src/Symfony/Component/Validator/ConstraintViolationList.php @@ -46,7 +46,7 @@ public static function createFromMessage(string $message): self } /** - * Converts the violation into a string for debugging purposes. + * {@inheritdoc} */ public function __toString(): string { diff --git a/src/Symfony/Component/Validator/ConstraintViolationListInterface.php b/src/Symfony/Component/Validator/ConstraintViolationListInterface.php index 85eafd65e74f3..241e426105105 100644 --- a/src/Symfony/Component/Validator/ConstraintViolationListInterface.php +++ b/src/Symfony/Component/Validator/ConstraintViolationListInterface.php @@ -18,6 +18,8 @@ * * @extends \ArrayAccess * @extends \Traversable + * + * @method string __toString() Converts the violation into a string for debugging purposes. Not implementing it is deprecated since Symfony 6.1. */ interface ConstraintViolationListInterface extends \Traversable, \Countable, \ArrayAccess {