Skip to content

Commit d4f9553

Browse files
committed
fix: reviews
1 parent 3516d22 commit d4f9553

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Symfony/Component/Validator/Constraints/ChoiceValidator.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ public function validate($value, Constraint $constraint)
3535
throw new UnexpectedTypeException($constraint, Choice::class);
3636
}
3737

38-
if (!\is_array($constraint->choices) && !is_a($constraint->choices, \BackedEnum::class, true) && !$constraint->callback) {
38+
$valid = \is_array($constraint->choices)
39+
|| (\is_string($constraint->choices) && \is_a($constraint->choices, \BackedEnum::class, true))
40+
|| isset($constraint->callback);
41+
42+
if (!$valid) {
3943
throw new ConstraintDefinitionException('Either "choices" or "callback" must be specified on constraint Choice.');
4044
}
4145

@@ -55,7 +59,7 @@ public function validate($value, Constraint $constraint)
5559
throw new ConstraintDefinitionException('The Choice constraint expects a valid callback.');
5660
}
5761
$choices = $choices();
58-
} elseif (is_a($constraint->choices, \BackedEnum::class, true)) {
62+
} elseif (\is_a($constraint->choices, \BackedEnum::class, true)) {
5963
$choices = array_map(
6064
function (\BackedEnum $enum) {
6165
return $enum->value;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy