Skip to content

Commit e4fba8e

Browse files
author
symfonyaml
committed
Use is_iterable as xabbuh suggested
1 parent 587c291 commit e4fba8e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ public function validate($value, Constraint $constraint)
5555
throw new ConstraintDefinitionException('The Choice constraint expects a valid callback.');
5656
}
5757
$choices = $choices();
58-
if ($choices instanceof \Traversable) {
59-
$choices = iterator_to_array($choices);
60-
}
6158
if (!is_array($choices)) {
62-
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)));
59+
if (!is_iterable($choices)) {
60+
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)));
61+
}
62+
$choices = iterator_to_array($choices);
6363
}
6464
} else {
6565
$choices = $constraint->choices;

0 commit comments

Comments
 (0)