From 7fa6babb473fa77f9b6c7ef03866fb1ca5f1d0ae Mon Sep 17 00:00:00 2001 From: Alexander Kras'ko <0m3r.mail@gmail.com> Date: Thu, 13 Oct 2022 10:44:03 +0300 Subject: [PATCH] Optimize latest version detection; set array_reduce initial param --- Model/ComponentList/Loader/Remote.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Model/ComponentList/Loader/Remote.php b/Model/ComponentList/Loader/Remote.php index 1aa4840..8f2cf4e 100644 --- a/Model/ComponentList/Loader/Remote.php +++ b/Model/ComponentList/Loader/Remote.php @@ -107,11 +107,11 @@ public function getComponentsInfo() foreach ($response['packages'] as $packageName => $info) { $versions = array_keys($info); $latestVersion = array_reduce($versions, function ($carry, $item) { - if ((!$carry && $item) || version_compare($carry, $item) === -1) { + if (version_compare($carry, $item) === -1) { $carry = $item; } return $carry; - }); + }, 0); if (!empty($info[$latestVersion]['type']) && $info[$latestVersion]['type'] === 'metapackage') {