Skip to content

Commit

Permalink
Optimize latest version detection; set array_reduce initial param
Browse files Browse the repository at this point in the history
  • Loading branch information
0m3r committed Oct 13, 2022
1 parent d22180d commit 7fa6bab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Model/ComponentList/Loader/Remote.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') {

Expand Down

0 comments on commit 7fa6bab

Please sign in to comment.