mirror of
https://github.com/symfony/validator.git
synced 2026-03-24 01:12:13 +01:00
Merge branch '6.4' into 7.2
* 6.4: - CS fixes
This commit is contained in:
@@ -53,8 +53,8 @@ class ChoiceValidator extends ConstraintValidator
|
||||
throw new ConstraintDefinitionException('The Choice constraint expects a valid callback.');
|
||||
}
|
||||
$choices = $choices();
|
||||
if (!is_array($choices)) {
|
||||
throw new ConstraintDefinitionException(sprintf('The Choice constraint callback "%s" is expected to return an array, but returned "%s".', trim($this->formatValue($constraint->callback), '"'), get_debug_type($choices)));
|
||||
if (!\is_array($choices)) {
|
||||
throw new ConstraintDefinitionException(\sprintf('The Choice constraint callback "%s" is expected to return an array, but returned "%s".', trim($this->formatValue($constraint->callback), '"'), get_debug_type($choices)));
|
||||
}
|
||||
} else {
|
||||
$choices = $constraint->choices;
|
||||
|
||||
@@ -43,8 +43,8 @@ final class WeekValidator extends ConstraintValidator
|
||||
return;
|
||||
}
|
||||
|
||||
[$year, $weekNumber] = \explode('-W', $value, 2);
|
||||
$weeksInYear = (int) \date('W', \mktime(0, 0, 0, 12, 28, $year));
|
||||
[$year, $weekNumber] = explode('-W', $value, 2);
|
||||
$weeksInYear = (int) date('W', mktime(0, 0, 0, 12, 28, $year));
|
||||
|
||||
if ($weekNumber > $weeksInYear) {
|
||||
$this->context->buildViolation($constraint->invalidWeekNumberMessage)
|
||||
@@ -56,7 +56,7 @@ final class WeekValidator extends ConstraintValidator
|
||||
}
|
||||
|
||||
if ($constraint->min) {
|
||||
[$minYear, $minWeekNumber] = \explode('-W', $constraint->min, 2);
|
||||
[$minYear, $minWeekNumber] = explode('-W', $constraint->min, 2);
|
||||
if ($year < $minYear || ($year === $minYear && $weekNumber < $minWeekNumber)) {
|
||||
$this->context->buildViolation($constraint->tooLowMessage)
|
||||
->setCode(Week::TOO_LOW_ERROR)
|
||||
@@ -69,7 +69,7 @@ final class WeekValidator extends ConstraintValidator
|
||||
}
|
||||
|
||||
if ($constraint->max) {
|
||||
[$maxYear, $maxWeekNumber] = \explode('-W', $constraint->max, 2);
|
||||
[$maxYear, $maxWeekNumber] = explode('-W', $constraint->max, 2);
|
||||
if ($year > $maxYear || ($year === $maxYear && $weekNumber > $maxWeekNumber)) {
|
||||
$this->context->buildViolation($constraint->tooHighMessage)
|
||||
->setCode(Week::TOO_HIGH_ERROR)
|
||||
|
||||
@@ -101,7 +101,7 @@ class LocaleValidatorTest extends ConstraintValidatorTestCase
|
||||
$this->validator->validate($locale, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', '"' . $locale . '"')
|
||||
->setParameter('{{ value }}', '"'.$locale.'"')
|
||||
->setCode(Locale::NO_SUCH_LOCALE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
@@ -36,11 +36,6 @@ class FilesLoaderTest extends TestCase
|
||||
|
||||
public function getFilesLoader(LoaderInterface $loader)
|
||||
{
|
||||
return new class([
|
||||
__DIR__.'/constraint-mapping.xml',
|
||||
__DIR__.'/constraint-mapping.yaml',
|
||||
__DIR__.'/constraint-mapping.test',
|
||||
__DIR__.'/constraint-mapping.txt',
|
||||
], $loader) extends FilesLoader {};
|
||||
return new class([__DIR__.'/constraint-mapping.xml', __DIR__.'/constraint-mapping.yaml', __DIR__.'/constraint-mapping.test', __DIR__.'/constraint-mapping.txt'], $loader) extends FilesLoader {};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user