From c2aeeeb04238876eb8ca1f1767d6cf4cce05d77f Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Thu, 29 Jan 2015 23:30:47 -0300 Subject: [PATCH] [2.7] [Form] Replaced calls to array_search() by in_array() where is no need to get the index | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | none | License | MIT | Doc PR | none --- src/Symfony/Bridge/Twig/Extension/FormExtension.php | 2 +- .../Component/Form/Extension/Core/ChoiceList/ChoiceList.php | 2 +- src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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) {