Skip to content

Commit 675cf95

Browse files
committed
Use array_key_last()
- see #4111 (comment)
1 parent 759d160 commit 675cf95

File tree

2 files changed

+4
-8
lines changed
  • app/code/core/Mage/Adminhtml

2 files changed

+4
-8
lines changed

app/code/core/Mage/Adminhtml/Block/Page/Menu.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,8 @@ protected function _buildMenuArray(Varien_Simplexml_Element $parent, $path = '',
164164

165165
uasort($parentArr, [$this, '_sortMenu']);
166166

167-
foreach (array_keys($parentArr) as $key) {
168-
$last = $key;
169-
}
170-
if (isset($last)) {
167+
$last = array_key_last($parentArr);
168+
if (!is_null($last)) {
171169
$parentArr[$last]['last'] = true;
172170
}
173171

app/code/core/Mage/Adminhtml/Model/System/Config/Source/Admin/Page.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,8 @@ protected function _buildMenuArray(?Varien_Simplexml_Element $parent = null, $pa
109109

110110
uasort($parentArr, [$this, '_sortMenu']);
111111

112-
foreach (array_keys($parentArr) as $key) {
113-
$last = $key;
114-
}
115-
if (isset($last)) {
112+
$last = array_key_last($parentArr);
113+
if (!is_null($last)) {
116114
$parentArr[$last]['last'] = true;
117115
}
118116

0 commit comments

Comments
 (0)