From 0d402cb2904e1aaff19d95616332462fdf519dec Mon Sep 17 00:00:00 2001 From: Marco Cesarato Date: Fri, 2 Apr 2021 10:25:56 +0200 Subject: [PATCH] fix: commit sorting on changelog Refs: #9 --- src/Changelog.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Changelog.php b/src/Changelog.php index 8cbb3b9..90b7948 100644 --- a/src/Changelog.php +++ b/src/Changelog.php @@ -267,12 +267,12 @@ public function generate(InputInterface $input, SymfonyStyle $output): int foreach ($options as $params) { $commitsRaw = Repository::getCommits($params['options']); usort($commitsRaw, function ($x, $y) use ($sortBy, $sortOrientation) { - if (is_array($x) && array_key_exists($sortBy, $x)) { + if (property_exists($x, $sortBy)) { if ($sortOrientation === 'ASC') { - return $x[$sortBy] <=> $y[$sortBy]; + return $x->{$sortBy} <=> $y->{$sortBy}; } - return $y[$sortBy] <=> $x[$sortBy]; + return $y->{$sortBy} <=> $x->{$sortBy}; } return 0;