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: src/Symfony/Component/Validator/Constraints/Locale.php
+9Lines changed: 9 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -29,4 +29,13 @@ class Locale extends Constraint
29
29
30
30
public$message = 'This value is not a valid locale.';
31
31
public$canonicalize = false;
32
+
33
+
publicfunction__construct($options = null)
34
+
{
35
+
if (!($options['canonicalize'] ?? false)) {
36
+
@trigger_error('The "canonicalize" option with value `false` is deprecated since Symfony 4.1 and will be removed in 5.0. Set it to `true` instead.', E_USER_DEPRECATED);
Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php
+91-11Lines changed: 91 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -22,47 +22,123 @@ protected function createValidator()
22
22
returnnewLocaleValidator();
23
23
}
24
24
25
-
publicfunctiontestNullIsValid()
25
+
/**
26
+
* @group legacy
27
+
* @expectedDeprecation The "canonicalize" option with value `false` is deprecated since Symfony 4.1 and will be removed in 5.0. Set it to `true` instead.
* @expectedDeprecation The "canonicalize" option with value `false` is deprecated since Symfony 4.1 and will be removed in 5.0. Set it to `true` instead.
* @expectedDeprecation The "canonicalize" option with value `false` is deprecated since Symfony 4.1 and will be removed in 5.0. Set it to `true` instead.
* @expectedDeprecation The "canonicalize" option with value `false` is deprecated since Symfony 4.1 and will be removed in 5.0. Set it to `true` instead.
* @expectedDeprecation The "canonicalize" option with value `false` is deprecated since Symfony 4.1 and will be removed in 5.0. Set it to `true` instead.
@@ -73,6 +149,7 @@ public function testInvalidLocales($locale)
73
149
{
74
150
$constraint = newLocale(array(
75
151
'message' => 'myMessage',
152
+
'canonicalize' => true,
76
153
));
77
154
78
155
$this->validator->validate($locale, $constraint);
@@ -86,12 +163,15 @@ public function testInvalidLocales($locale)
86
163
publicfunctiongetInvalidLocales()
87
164
{
88
165
returnarray(
89
-
array('EN'),
166
+
array('baz'),
90
167
array('foobar'),
168
+
array('en-us.utf8@VARIANT'),
91
169
);
92
170
}
93
171
94
172
/**
173
+
* @group legacy
174
+
* @expectedDeprecation The "canonicalize" option with value `false` is deprecated since Symfony 4.1 and will be removed in 5.0. Set it to `true` instead.
0 commit comments