From 3d05667a59f828a66126ba70ba428920f613252c Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 8 Jun 2023 15:16:48 -0500 Subject: [PATCH] Revert "[10.x] Update Kernel::load() to use same `classFromFile` logic as events (#47327)" This reverts commit 2b174d50daf0598e8ea04586e1e0e97e4b9880eb. --- src/Illuminate/Foundation/Console/Kernel.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Illuminate/Foundation/Console/Kernel.php b/src/Illuminate/Foundation/Console/Kernel.php index da77b1ab22e3..334b3a401b43 100644 --- a/src/Illuminate/Foundation/Console/Kernel.php +++ b/src/Illuminate/Foundation/Console/Kernel.php @@ -332,15 +332,12 @@ protected function load($paths) } $namespace = $this->app->getNamespace(); - $basePath = $this->app->basePath(); - foreach ((new Finder())->in($paths)->files() as $file) { - $class = trim(Str::replaceFirst($basePath, '', $file->getRealPath()), DIRECTORY_SEPARATOR); - - $command = str_replace( - [DIRECTORY_SEPARATOR, ucfirst(basename($this->app->path())).'\\'], - ['\\', $namespace], - ucfirst(Str::replaceLast('.php', '', $class)), + foreach ((new Finder)->in($paths)->files() as $command) { + $command = $namespace.str_replace( + ['/', '.php'], + ['\\', ''], + Str::after($command->getRealPath(), realpath(app_path()).DIRECTORY_SEPARATOR) ); if (is_subclass_of($command, Command::class) &&