Skip to content

Commit 9bcfbae

Browse files
Merge branch '4.4'
* 4.4: [travis] Fix build-packages script Add types to constructors and private/final/internal methods (Batch III) [HttpClient] Async HTTPlug client [Messenger] Allow to configure the db index on Redis transport [HttpClient] bugfix exploding values of headers [VarDumper] Made all casters final [VarDumper] Added a support for casting Ramsey/Uuid Remove useless testCanCheckIfTerminalIsInteractive test case [Validator] Add the missing translations for the Thai (\"th\") locale [Routing] gracefully handle docref_root ini setting [Validator] Fix ValidValidator group cascading usage
2 parents f9786e5 + 77c3bcb commit 9bcfbae

File tree

9 files changed

+99
-26
lines changed

9 files changed

+99
-26
lines changed

Constraints/AbstractComparisonValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function validate($value, Constraint $constraint)
9191
}
9292
}
9393

94-
private function getPropertyAccessor()
94+
private function getPropertyAccessor(): PropertyAccessorInterface
9595
{
9696
if (null === $this->propertyAccessor) {
9797
$this->propertyAccessor = PropertyAccess::createPropertyAccessor();

Constraints/ExpressionValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function validate($value, Constraint $constraint)
5050
}
5151
}
5252

53-
private function getExpressionLanguage()
53+
private function getExpressionLanguage(): ExpressionLanguage
5454
{
5555
if (null === $this->expressionLanguage) {
5656
$this->expressionLanguage = new ExpressionLanguage();

Constraints/FileValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ private static function moreDecimalsThan(string $double, int $numberOfDecimals):
208208
* Convert the limit to the smallest possible number
209209
* (i.e. try "MB", then "kB", then "bytes").
210210
*/
211-
private function factorizeSizes(int $size, int $limit, bool $binaryFormat)
211+
private function factorizeSizes(int $size, int $limit, bool $binaryFormat): array
212212
{
213213
if ($binaryFormat) {
214214
$coef = self::MIB_BYTES;

Constraints/IbanValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public function validate($value, Constraint $constraint)
225225
}
226226
}
227227

228-
private static function toBigInt($string)
228+
private static function toBigInt(string $string): string
229229
{
230230
$chars = str_split($string);
231231
$bigInt = '';
@@ -245,7 +245,7 @@ private static function toBigInt($string)
245245
return $bigInt;
246246
}
247247

248-
private static function bigModulo97($bigInt)
248+
private static function bigModulo97(string $bigInt): int
249249
{
250250
$parts = str_split($bigInt, 7);
251251
$rest = 0;

Constraints/ValidValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ public function validate($value, Constraint $constraint)
3333
$this->context
3434
->getValidator()
3535
->inContext($this->context)
36-
->validate($value, null, [$this->context->getGroup()]);
36+
->validate($value, null, $this->context->getGroup());
3737
}
3838
}

Context/ExecutionContext.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414
use Symfony\Component\Validator\Constraint;
1515
use Symfony\Component\Validator\ConstraintViolation;
1616
use Symfony\Component\Validator\ConstraintViolationList;
17+
use Symfony\Component\Validator\ConstraintViolationListInterface;
1718
use Symfony\Component\Validator\Mapping\ClassMetadataInterface;
1819
use Symfony\Component\Validator\Mapping\MemberMetadata;
1920
use Symfony\Component\Validator\Mapping\MetadataInterface;
2021
use Symfony\Component\Validator\Mapping\PropertyMetadataInterface;
2122
use Symfony\Component\Validator\Util\PropertyPath;
2223
use Symfony\Component\Validator\Validator\ValidatorInterface;
2324
use Symfony\Component\Validator\Violation\ConstraintViolationBuilder;
25+
use Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface;
2426
use Symfony\Contracts\Translation\TranslatorInterface;
2527

2628
/**
@@ -188,7 +190,7 @@ public function addViolation(string $message, array $parameters = [])
188190
/**
189191
* {@inheritdoc}
190192
*/
191-
public function buildViolation(string $message, array $parameters = [])
193+
public function buildViolation(string $message, array $parameters = []): ConstraintViolationBuilderInterface
192194
{
193195
return new ConstraintViolationBuilder(
194196
$this->violations,
@@ -206,15 +208,15 @@ public function buildViolation(string $message, array $parameters = [])
206208
/**
207209
* {@inheritdoc}
208210
*/
209-
public function getViolations()
211+
public function getViolations(): ConstraintViolationListInterface
210212
{
211213
return $this->violations;
212214
}
213215

214216
/**
215217
* {@inheritdoc}
216218
*/
217-
public function getValidator()
219+
public function getValidator(): ValidatorInterface
218220
{
219221
return $this->validator;
220222
}
@@ -246,44 +248,44 @@ public function getObject()
246248
/**
247249
* {@inheritdoc}
248250
*/
249-
public function getMetadata()
251+
public function getMetadata(): ?MetadataInterface
250252
{
251253
return $this->metadata;
252254
}
253255

254256
/**
255257
* {@inheritdoc}
256258
*/
257-
public function getGroup()
259+
public function getGroup(): ?string
258260
{
259261
return $this->group;
260262
}
261263

262-
public function getConstraint()
264+
public function getConstraint(): ?Constraint
263265
{
264266
return $this->constraint;
265267
}
266268

267269
/**
268270
* {@inheritdoc}
269271
*/
270-
public function getClassName()
272+
public function getClassName(): ?string
271273
{
272274
return $this->metadata instanceof MemberMetadata || $this->metadata instanceof ClassMetadataInterface ? $this->metadata->getClassName() : null;
273275
}
274276

275277
/**
276278
* {@inheritdoc}
277279
*/
278-
public function getPropertyName()
280+
public function getPropertyName(): ?string
279281
{
280282
return $this->metadata instanceof PropertyMetadataInterface ? $this->metadata->getPropertyName() : null;
281283
}
282284

283285
/**
284286
* {@inheritdoc}
285287
*/
286-
public function getPropertyPath(string $subPath = '')
288+
public function getPropertyPath(string $subPath = ''): string
287289
{
288290
return PropertyPath::append($this->propertyPath, $subPath);
289291
}
@@ -303,7 +305,7 @@ public function markGroupAsValidated(string $cacheKey, string $groupHash)
303305
/**
304306
* {@inheritdoc}
305307
*/
306-
public function isGroupValidated(string $cacheKey, string $groupHash)
308+
public function isGroupValidated(string $cacheKey, string $groupHash): bool
307309
{
308310
return isset($this->validatedObjects[$cacheKey][$groupHash]);
309311
}
@@ -319,7 +321,7 @@ public function markConstraintAsValidated(string $cacheKey, string $constraintHa
319321
/**
320322
* {@inheritdoc}
321323
*/
322-
public function isConstraintValidated(string $cacheKey, string $constraintHash)
324+
public function isConstraintValidated(string $cacheKey, string $constraintHash): bool
323325
{
324326
return isset($this->validatedConstraints[$cacheKey.':'.$constraintHash]);
325327
}
@@ -335,7 +337,7 @@ public function markObjectAsInitialized(string $cacheKey)
335337
/**
336338
* {@inheritdoc}
337339
*/
338-
public function isObjectInitialized(string $cacheKey)
340+
public function isObjectInitialized(string $cacheKey): bool
339341
{
340342
return isset($this->initializedObjects[$cacheKey]);
341343
}

Resources/translations/validators.th.xlf

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@
204204
</trans-unit>
205205
<trans-unit id="54">
206206
<source>This collection should contain {{ limit }} element or more.|This collection should contain {{ limit }} elements or more.</source>
207-
<target>คอเล็กชั่นนี้ควรจะประกอบไปด้วยอ่างน้อย {{ limit }} สมาชิก</target>
207+
<target>คอเล็กชั่นนี้ควรจะประกอบไปด้วยอย่างน้อย {{ limit }} สมาชิก</target>
208208
</trans-unit>
209209
<trans-unit id="55">
210210
<source>This collection should contain {{ limit }} element or less.|This collection should contain {{ limit }} elements or less.</source>
@@ -298,6 +298,74 @@
298298
<source>The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed.</source>
299299
<target>ภาพนี้เป็นแนวตั้ง ({{ width }}x{{ height }}px) ไม่อนุญาตภาพที่เป็นแนวตั้ง</target>
300300
</trans-unit>
301+
<trans-unit id="78">
302+
<source>An empty file is not allowed.</source>
303+
<target>ไม่อนุญาตให้ใช้ไฟล์ว่าง</target>
304+
</trans-unit>
305+
<trans-unit id="79">
306+
<source>The host could not be resolved.</source>
307+
<target>ไม่สามารถแก้ไขชื่อโฮสต์</target>
308+
</trans-unit>
309+
<trans-unit id="80">
310+
<source>This value does not match the expected {{ charset }} charset.</source>
311+
<target>ค่านี้ไม่ตรงกับการเข้ารหัส {{ charset }}</target>
312+
</trans-unit>
313+
<trans-unit id="81">
314+
<source>This is not a valid Business Identifier Code (BIC).</source>
315+
<target>นี่ไม่ถูกต้องตามรหัสสำหรับระบุธุรกิจนี้ (BIC)</target>
316+
</trans-unit>
317+
<trans-unit id="82">
318+
<source>Error</source>
319+
<target>เกิดข้อผิดพลาด</target>
320+
</trans-unit>
321+
<trans-unit id="83">
322+
<source>This is not a valid UUID.</source>
323+
<target>นี่ไม่ใช่ UUID ที่ถูกต้อง</target>
324+
</trans-unit>
325+
<trans-unit id="84">
326+
<source>This value should be a multiple of {{ compared_value }}.</source>
327+
<target>ค่านี้ควรเป็น {{ compared_value }} หลายตัว</target>
328+
</trans-unit>
329+
<trans-unit id="85">
330+
<source>This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}.</source>
331+
<target>รหัสสำหรับระบุธุรกิจนี้ (BIC) ไม่เกี่ยวข้องกับ IBAN {{ iban }}</target>
332+
</trans-unit>
333+
<trans-unit id="86">
334+
<source>This value should be valid JSON.</source>
335+
<target>ค่านี้ควรอยู่ในรูปแบบ JSON ที่ถูกต้อง</target>
336+
</trans-unit>
337+
<trans-unit id="87">
338+
<source>This collection should contain only unique elements.</source>
339+
<target>คอเล็กชั่นนี้ควรมีเฉพาะสมาชิกที่ไม่ซ้ำกันเท่านั้น</target>
340+
</trans-unit>
341+
<trans-unit id="88">
342+
<source>This value should be positive.</source>
343+
<target>ค่านี้ควรเป็นค่าบวก</target>
344+
</trans-unit>
345+
<trans-unit id="89">
346+
<source>This value should be either positive or zero.</source>
347+
<target>ค่านี้ควรเป็นค่าบวกหรือค่าศูนย์</target>
348+
</trans-unit>
349+
<trans-unit id="90">
350+
<source>This value should be negative.</source>
351+
<target>ค่านี้ควรเป็นค่าลบ</target>
352+
</trans-unit>
353+
<trans-unit id="91">
354+
<source>This value should be either negative or zero.</source>
355+
<target>ค่านี้ควรเป็นค่าลบหรือค่าศูนย์</target>
356+
</trans-unit>
357+
<trans-unit id="92">
358+
<source>This value is not a valid timezone.</source>
359+
<target>ค่าเขตเวลาไม่ถูกต้อง</target>
360+
</trans-unit>
361+
<trans-unit id="93">
362+
<source>This password has been leaked in a data breach, it must not be used. Please use another password.</source>
363+
<target>รหัสผ่านนี้ได้เคยรั่วไหลออกไปโดยถูกการละเมิดข้อมูล ซึ่งไม่ควรนำกลับมาใช้ กรุณาใช้รหัสผ่านอื่น</target>
364+
</trans-unit>
365+
<trans-unit id="94">
366+
<source>This value should be between {{ min }} and {{ max }}.</source>
367+
<target>ค่านี้ควรอยู่ระหว่าง {{ min }} ถึง {{ max }}</target>
368+
</trans-unit>
301369
</body>
302370
</file>
303371
</xliff>

Test/ConstraintValidatorTestCase.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,22 +234,22 @@ class ConstraintViolationAssertion
234234
private $constraint;
235235
private $cause;
236236

237-
public function __construct(ExecutionContextInterface $context, $message, Constraint $constraint = null, array $assertions = [])
237+
public function __construct(ExecutionContextInterface $context, string $message, Constraint $constraint = null, array $assertions = [])
238238
{
239239
$this->context = $context;
240240
$this->message = $message;
241241
$this->constraint = $constraint;
242242
$this->assertions = $assertions;
243243
}
244244

245-
public function atPath($path)
245+
public function atPath(string $path)
246246
{
247247
$this->propertyPath = $path;
248248

249249
return $this;
250250
}
251251

252-
public function setParameter($key, $value)
252+
public function setParameter(string $key, $value)
253253
{
254254
$this->parameters[$key] = $value;
255255

@@ -277,14 +277,14 @@ public function setInvalidValue($invalidValue)
277277
return $this;
278278
}
279279

280-
public function setPlural($number)
280+
public function setPlural(int $number)
281281
{
282282
$this->plural = $number;
283283

284284
return $this;
285285
}
286286

287-
public function setCode($code)
287+
public function setCode(string $code)
288288
{
289289
$this->code = $code;
290290

@@ -298,7 +298,7 @@ public function setCause($cause)
298298
return $this;
299299
}
300300

301-
public function buildNextViolation($message)
301+
public function buildNextViolation(string $message): self
302302
{
303303
$assertions = $this->assertions;
304304
$assertions[] = $this;
@@ -326,7 +326,7 @@ public function assertRaised()
326326
}
327327
}
328328

329-
private function getViolation()
329+
private function getViolation(): ConstraintViolation
330330
{
331331
return new ConstraintViolation(
332332
$this->message,

Validation.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ public static function createValidator(): ValidatorInterface
3131
return self::createValidatorBuilder()->getValidator();
3232
}
3333

34+
/**
35+
* Creates a configurable builder for validator objects.
36+
*/
3437
public static function createValidatorBuilder(): ValidatorBuilder
3538
{
3639
return new ValidatorBuilder();

0 commit comments

Comments
 (0)