From 45b49df92e336cd2d3366fb91e7f545b06afc085 Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Tue, 22 Nov 2022 23:00:18 -0400 Subject: [PATCH 1/2] Simplify issue sorting As we're on 7.4 now, we can use more concise constructs --- src/Psalm/IssueBuffer.php | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/Psalm/IssueBuffer.php b/src/Psalm/IssueBuffer.php index b2b80511031..8fbbf6ce48f 100644 --- a/src/Psalm/IssueBuffer.php +++ b/src/Psalm/IssueBuffer.php @@ -574,21 +574,10 @@ public static function finish( foreach (self::$issues_data as $file_path => $file_issues) { usort( $file_issues, - static function (IssueData $d1, IssueData $d2): int { - if ($d1->file_path === $d2->file_path) { - if ($d1->line_from === $d2->line_from) { - if ($d1->column_from === $d2->column_from) { - return 0; - } - - return $d1->column_from > $d2->column_from ? 1 : -1; - } - - return $d1->line_from > $d2->line_from ? 1 : -1; - } - - return $d1->file_path > $d2->file_path ? 1 : -1; - } + static fn (IssueData $d1, IssueData $d2): int => + [$d1->file_path, $d1->line_from, $d1->column_from] + <=> + [$d2->file_path, $d2->line_from, $d2->column_from] ); self::$issues_data[$file_path] = $file_issues; } From 8e941c1439bd40dc006b43a22db0352e5330b42d Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Tue, 22 Nov 2022 23:59:10 -0400 Subject: [PATCH 2/2] CS fix --- src/Psalm/IssueBuffer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Psalm/IssueBuffer.php b/src/Psalm/IssueBuffer.php index 8fbbf6ce48f..b1750133ce6 100644 --- a/src/Psalm/IssueBuffer.php +++ b/src/Psalm/IssueBuffer.php @@ -574,7 +574,7 @@ public static function finish( foreach (self::$issues_data as $file_path => $file_issues) { usort( $file_issues, - static fn (IssueData $d1, IssueData $d2): int => + static fn(IssueData $d1, IssueData $d2): int => [$d1->file_path, $d1->line_from, $d1->column_from] <=> [$d2->file_path, $d2->line_from, $d2->column_from]