Skip to content

Commit

Permalink
Merge pull request #225 from pine3ree/3.12.x-get-out-of-the-loop
Browse files Browse the repository at this point in the history
Move array values string type-casting out of the loop
  • Loading branch information
Ocramius authored Jun 26, 2023
2 parents 193b2e5 + 749d67d commit 263d186
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/View/Helper/FormSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ public function renderOptions(array $options, array $selectedOptions = []): stri
$optionStrings = [];
$escapeHtml = $this->getEscapeHtmlHelper();

$stringSelectedOptions = array_map('strval', $selectedOptions);

foreach ($options as $key => $optionSpec) {
$value = '';
$label = '';
Expand Down Expand Up @@ -192,7 +194,6 @@ public function renderOptions(array $options, array $selectedOptions = []): stri
$disabled = $optionSpec['disabled'];
}

$stringSelectedOptions = array_map('\\strval', $selectedOptions);
if (ArrayUtils::inArray((string) $value, $stringSelectedOptions, true)) {
$selected = true;
}
Expand Down

0 comments on commit 263d186

Please sign in to comment.