From b6202ea60e9910c8e4453f6594395987503a5ce7 Mon Sep 17 00:00:00 2001 From: pine3ree Date: Mon, 26 Jun 2023 21:22:57 +0200 Subject: [PATCH 1/2] Move array values string type-casting out of the loop Signed-off-by: pine3ree --- src/View/Helper/FormSelect.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/View/Helper/FormSelect.php b/src/View/Helper/FormSelect.php index 8bf9449a0..1ebd39c57 100644 --- a/src/View/Helper/FormSelect.php +++ b/src/View/Helper/FormSelect.php @@ -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 = ''; @@ -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; } From 749d67dd4a0a3f6058c77c3bf26547ed2fed618a Mon Sep 17 00:00:00 2001 From: pine3ree Date: Tue, 27 Jun 2023 00:12:37 +0200 Subject: [PATCH 2/2] Remove unnecessary root namespace separator Signed-off-by: pine3ree --- src/View/Helper/FormSelect.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/View/Helper/FormSelect.php b/src/View/Helper/FormSelect.php index 1ebd39c57..6b1efc82d 100644 --- a/src/View/Helper/FormSelect.php +++ b/src/View/Helper/FormSelect.php @@ -161,7 +161,7 @@ public function renderOptions(array $options, array $selectedOptions = []): stri $optionStrings = []; $escapeHtml = $this->getEscapeHtmlHelper(); - $stringSelectedOptions = array_map('\\strval', $selectedOptions); + $stringSelectedOptions = array_map('strval', $selectedOptions); foreach ($options as $key => $optionSpec) { $value = '';