diff --git a/src/Symfony/Bridge/Twig/Extension/FormExtension.php b/src/Symfony/Bridge/Twig/Extension/FormExtension.php index fff092f012cb..9c7339f70295 100644 --- a/src/Symfony/Bridge/Twig/Extension/FormExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/FormExtension.php @@ -144,7 +144,7 @@ public function humanize($text) public function isSelectedChoice(ChoiceView $choice, $selectedValue) { if (is_array($selectedValue)) { - return false !== array_search($choice->value, $selectedValue, true); + return in_array($choice->value, $selectedValue, true); } return $choice->value === $selectedValue; diff --git a/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php b/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php index d9d00ef7d1ba..40e9d1a07537 100644 --- a/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php +++ b/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php @@ -381,7 +381,7 @@ protected function addChoice(array &$bucketForPreferred, array &$bucketForRemain */ protected function isPreferred($choice, array $preferredChoices) { - return false !== array_search($choice, $preferredChoices, true); + return in_array($choice, $preferredChoices, true); } /** diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index dc241779c92c..5520119fdfc3 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -111,7 +111,7 @@ public function buildView(FormView $view, FormInterface $form, array $options) // avoid making the type check inside the closure. if ($options['multiple']) { $view->vars['is_selected'] = function ($choice, array $values) { - return false !== array_search($choice, $values, true); + return in_array($choice, $values, true); }; } else { $view->vars['is_selected'] = function ($choice, $value) {