Skip to content

Commit 9c0b8e6

Browse files
committed
Merge branch 'feature/predictable-standards-order' of https://github.com/jrfnl/PHP_CodeSniffer
2 parents 2648741 + 0802c3c commit 9c0b8e6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Util/Standards.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ public static function getInstalledStandards(
180180
// Check if the installed dir is actually a standard itself.
181181
$csFile = $standardsDir.'/ruleset.xml';
182182
if (is_file($csFile) === true) {
183-
$installedStandards[] = basename($standardsDir);
183+
$basename = basename($standardsDir);
184+
$installedStandards[$basename] = $basename;
184185
continue;
185186
}
186187

@@ -190,6 +191,7 @@ public static function getInstalledStandards(
190191
}
191192

192193
$di = new \DirectoryIterator($standardsDir);
194+
$standardsInDir = [];
193195
foreach ($di as $file) {
194196
if ($file->isDir() === true && $file->isDot() === false) {
195197
$filename = $file->getFilename();
@@ -202,10 +204,13 @@ public static function getInstalledStandards(
202204
// Valid coding standard dirs include a ruleset.
203205
$csFile = $file->getPathname().'/ruleset.xml';
204206
if (is_file($csFile) === true) {
205-
$installedStandards[] = $filename;
207+
$standardsInDir[$filename] = $filename;
206208
}
207209
}
208210
}
211+
212+
natsort($standardsInDir);
213+
$installedStandards += $standardsInDir;
209214
}//end foreach
210215

211216
return $installedStandards;

0 commit comments

Comments
 (0)