From 631f16a183c54173c476a4fed4d0b9126abb7bee Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 6 Aug 2023 16:46:12 +0200 Subject: [PATCH] Ruleset::explain(): use natural sorting ... for the list of included sniffs. The `SORT_NATURAL` and the `SORT_FLAG_CASE` flag are available since PHP 5.4, so can be used without issue. --- CHANGELOG.md | 2 ++ src/Ruleset.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c46298fd6..0862f64ded 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -83,6 +83,8 @@ The file documents changes to the PHP_CodeSniffer project. - Thanks to @Daimona for the patch - Runtime performance improvement for PHPCS CLI users. The improvement should be most noticeable for users on Windows. - Thanks to Juliette Reinders Folmer (@jrfnl) for the patch +- The -e (explain) command will now list sniffs in natural order + - Thanks to Juliette Reinders Folmer (@jrfnl) for the patch ### Removed - Removed support for installing via PEAR diff --git a/src/Ruleset.php b/src/Ruleset.php index 82facade1e..bd0527dcb5 100644 --- a/src/Ruleset.php +++ b/src/Ruleset.php @@ -238,7 +238,7 @@ public function __construct(Config $config) public function explain() { $sniffs = array_keys($this->sniffCodes); - sort($sniffs); + sort($sniffs, (SORT_NATURAL | SORT_FLAG_CASE)); $sniffCount = count($sniffs);