Skip to content

Commit

Permalink
Sort issue by position in codebase in ByIssueLevelAndTypeReport if le…
Browse files Browse the repository at this point in the history
…vel & type equal

PHP sorting only became stable in 8.0. For previous versions we would
still like duplicate issues to be sorted into a logical order.
  • Loading branch information
bdsl committed Dec 2, 2022
1 parent a29f65e commit ad57727
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Psalm/Report/ByIssueLevelAndTypeReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ private function sortIssuesByLevelAndType(): void
{
usort($this->issues_data, function (IssueData $left, IssueData $right): int {
// negative error levels go to the top, followed by large positive levels, with level 1 at the bottom.
return [$left->error_level > 0, -$left->error_level, $left->type] <=>
[$right->error_level > 0, -$right->error_level, $right->type];
return [$left->error_level > 0, -$left->error_level, $left->type, $left->file_path, $left->file_name, $left->line_from] <=>
[$right->error_level > 0, -$right->error_level, $right->type, $right->file_path, $right->file_name, $right->line_from];
});
}
}

0 comments on commit ad57727

Please sign in to comment.