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
+9
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('"canonicalize" option with value `false` is deprecated since Symfony 4.1 and will be removed in 5.0. Use "canonicalize"=>true instead.', E_USER_DEPRECATED);
Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php
+92-12
Original file line number
Diff line number
Diff line change
@@ -22,57 +22,134 @@ protected function createValidator()
22
22
returnnewLocaleValidator();
23
23
}
24
24
25
-
publicfunctiontestNullIsValid()
25
+
/**
26
+
* @group legacy
27
+
* @expectedDeprecation "canonicalize" option with value `false` is deprecated since Symfony 4.1 and will be removed in 5.0. Use "canonicalize"=>true instead.
* @expectedDeprecation "canonicalize" option with value `false` is deprecated since Symfony 4.1 and will be removed in 5.0. Use "canonicalize"=>true instead.
* @expectedDeprecation "canonicalize" option with value `false` is deprecated since Symfony 4.1 and will be removed in 5.0. Use "canonicalize"=>true instead.
* @expectedDeprecation "canonicalize" option with value `false` is deprecated since Symfony 4.1 and will be removed in 5.0. Use "canonicalize"=>true instead.
* @expectedDeprecation "canonicalize" option with value `false` is deprecated since Symfony 4.1 and will be removed in 5.0. Use "canonicalize"=>true instead.
121
+
* @dataProvider getLegacyInvalidLocales
122
+
*/
123
+
publicfunctiontestLegacyInvalidLocales($locale)
124
+
{
125
+
$constraint = newLocale(array(
126
+
'message' => 'myMessage',
127
+
));
128
+
129
+
$this->validator->validate($locale, $constraint);
130
+
131
+
$this->buildViolation('myMessage')
132
+
->setParameter('{{ value }}', '"'.$locale.'"')
133
+
->setCode(Locale::NO_SUCH_LOCALE_ERROR)
134
+
->assertRaised();
135
+
}
136
+
137
+
publicfunctiongetLegacyInvalidLocales()
138
+
{
139
+
returnarray(
140
+
array('EN'),
141
+
array('foobar'),
66
142
);
67
143
}
68
144
69
145
/**
70
146
* @dataProvider getInvalidLocales
71
147
*/
72
-
publicfunctiontestInvalidLocales($locale)
148
+
publicfunctiontestInvalidLocales(string$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'),
91
168
);
92
169
}
93
170
94
171
/**
172
+
*
173
+
* @group legacy
174
+
* @expectedDeprecation "canonicalize" option with value `false` is deprecated since Symfony 4.1 and will be removed in 5.0. Use "canonicalize"=>true instead.
0 commit comments