From f3d841c0a30645a8bbf908e89ab31acf0053ad93 Mon Sep 17 00:00:00 2001 From: Markus Podar Date: Sun, 28 Jun 2020 11:21:36 +0200 Subject: [PATCH] Sort models found in file system (#982) Ensures they're always ordered / processed independent of the environment. `ClassMapGenerator::createMap` uses symfony/finder which itself supports sorting but this isn't used from the `ClassMapGenerator`. Fixes https://github.com/barryvdh/laravel-ide-helper/issues/885 --- src/Console/ModelsCommand.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index e82d8b7..95a7b2f 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -276,7 +276,12 @@ class ModelsCommand extends Command $dirs = glob($dir, GLOB_ONLYDIR); foreach ($dirs as $dir) { if (file_exists($dir)) { - foreach (ClassMapGenerator::createMap($dir) as $model => $path) { + $classMap = ClassMapGenerator::createMap($dir); + + // Sort list so it's stable across different environments + ksort($classMap); + + foreach ($classMap as $model => $path) { $models[] = $model; } }