mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-23 23:33:54 +00:00
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
This commit is contained in:
parent
32d9da47fb
commit
4d8c06cadb
|
@ -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(),
|
||||
|
|
Loading…
Reference in a new issue