Skip to content

Commit 6bc6173

Browse files
phansysfabpot
authored andcommitted
[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
1 parent 199f994 commit 6bc6173

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Extension/Core/ChoiceList/ChoiceList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ protected function addChoice(array &$bucketForPreferred, array &$bucketForRemain
381381
*/
382382
protected function isPreferred($choice, array $preferredChoices)
383383
{
384-
return false !== array_search($choice, $preferredChoices, true);
384+
return in_array($choice, $preferredChoices, true);
385385
}
386386

387387
/**

Extension/Core/Type/ChoiceType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function buildView(FormView $view, FormInterface $form, array $options)
111111
// avoid making the type check inside the closure.
112112
if ($options['multiple']) {
113113
$view->vars['is_selected'] = function ($choice, array $values) {
114-
return false !== array_search($choice, $values, true);
114+
return in_array($choice, $values, true);
115115
};
116116
} else {
117117
$view->vars['is_selected'] = function ($choice, $value) {

0 commit comments

Comments
 (0)