From 4d8c06cadb247fdcda841de6b2f9c1c50db89a7e Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Fri, 12 Jan 2024 01:25:40 +0100 Subject: [PATCH] VectorComponentUserLinks: Replace array_reduce with array_filter Looks easier to understand: array_reduce adds the count() of all inner arrays and returns an integer, 0 when all is empty and the count when items in there. array_filter removes the empty inner arrays and when the returned outer array still has an inner array, it is non-empty. Change-Id: Ib0acb9be8d4d64cfb7d7d124c5a3de500f6b0232 --- includes/Components/VectorComponentUserLinks.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/includes/Components/VectorComponentUserLinks.php b/includes/Components/VectorComponentUserLinks.php index 3a9702fbe..1cc851a56 100644 --- a/includes/Components/VectorComponentUserLinks.php +++ b/includes/Components/VectorComponentUserLinks.php @@ -320,13 +320,9 @@ class VectorComponentUserLinks implements VectorComponent { ] ); return [ - 'is-wide' => array_reduce( - [ $overflow, $notifications, $userPage, $userInterfacePreferences ], - static function ( $carry, $list ) { - return count( $list ) + $carry; - }, - 0 - ), + 'is-wide' => array_filter( + [ $overflow, $notifications, $userPage, $userInterfacePreferences ] + ) !== [], 'data-user-links-notifications' => $notificationsMenu->getTemplateData(), 'data-user-links-overflow' => $overflowMenu->getTemplateData(), 'data-user-links-preferences' => $preferencesMenu->getTemplateData(),