Skip to content

Commit 88e1403

Browse files
author
symfonyaml
committed
Fix psalm issue $choices Traversable
1 parent e4fba8e commit 88e1403

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@ public function validate($value, Constraint $constraint)
5656
}
5757
$choices = $choices();
5858
if (!is_array($choices)) {
59-
if (!is_iterable($choices)) {
59+
if (is_iterable($choices)) {
60+
/** @psalm-suppress InvalidArgument */
61+
$choices = iterator_to_array($choices);
62+
} else {
6063
throw new ConstraintDefinitionException(sprintf('The Choice constraint callback "%s" expects to return an iterable, got "%s".', trim($this->formatValue($constraint->callback), '"'), get_debug_type($choices)));
6164
}
62-
$choices = iterator_to_array($choices);
6365
}
6466
} else {
6567
$choices = $constraint->choices;

0 commit comments

Comments
 (0)