You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,9 @@ CHANGELOG
4
4
4.4.0
5
5
-----
6
6
7
+
* using anything else than a `string` as the code of a `ConstraintViolation` is deprecated, a `string` type-hint will
8
+
be added to the constructor of the `ConstraintViolation` class and to the `ConstraintViolationBuilder::setCode()`
9
+
method in 5.0
7
10
* deprecated passing an `ExpressionLanguage` instance as the second argument of `ExpressionValidator::__construct()`. Pass it as the first argument instead.
8
11
* added the `compared_value_path` parameter in violations when using any
9
12
comparison constraint with the `propertyPath` option.
Copy file name to clipboardExpand all lines: ConstraintViolation.php
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -56,6 +56,10 @@ public function __construct(?string $message, ?string $messageTemplate, array $p
56
56
$message = '';
57
57
}
58
58
59
+
if (null !== $code && !\is_string($code)) {
60
+
@trigger_error(sprintf('Not using a string as the error code in %s() is deprecated since Symfony 4.4. A type-hint will be added in 5.0.', __METHOD__), E_USER_DEPRECATED);
* @expectedDeprecation Not using a string as the error code in Symfony\Component\Validator\ConstraintViolation::__construct() is deprecated since Symfony 4.4. A type-hint will be added in 5.0.
class ConstraintViolationBuilderTest extends TestCase
21
+
{
22
+
/**
23
+
* @group legacy
24
+
* @expectedDeprecation Not using a string as the error code in Symfony\Component\Validator\Violation\ConstraintViolationBuilder::setCode() is deprecated since Symfony 4.4. A type-hint will be added in 5.0.
25
+
* @expectedDeprecation Not using a string as the error code in Symfony\Component\Validator\ConstraintViolation::__construct() is deprecated since Symfony 4.4. A type-hint will be added in 5.0.
Copy file name to clipboardExpand all lines: Violation/ConstraintViolationBuilder.php
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -132,6 +132,10 @@ public function setPlural($number)
132
132
*/
133
133
publicfunctionsetCode($code)
134
134
{
135
+
if (null !== $code && !\is_string($code)) {
136
+
@trigger_error(sprintf('Not using a string as the error code in %s() is deprecated since Symfony 4.4. A type-hint will be added in 5.0.', __METHOD__), E_USER_DEPRECATED);
0 commit comments