From 1a68b63d304c0a00c5eba9a6756d8345b05ac034 Mon Sep 17 00:00:00 2001 From: cwhite Date: Fri, 2 Jun 2023 08:24:03 -0500 Subject: [PATCH 1/2] Update Kernel::load() to use same `classFromFile` logic as events --- src/Illuminate/Foundation/Console/Kernel.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Illuminate/Foundation/Console/Kernel.php b/src/Illuminate/Foundation/Console/Kernel.php index 334b3a401b43..77472eeaa74d 100644 --- a/src/Illuminate/Foundation/Console/Kernel.php +++ b/src/Illuminate/Foundation/Console/Kernel.php @@ -332,12 +332,15 @@ protected function load($paths) } $namespace = $this->app->getNamespace(); + $basePath = $this->app->basePath(); - foreach ((new Finder)->in($paths)->files() as $command) { - $command = $namespace.str_replace( - ['/', '.php'], - ['\\', ''], - Str::after($command->getRealPath(), realpath(app_path()).DIRECTORY_SEPARATOR) + foreach ((new Finder())->in($paths)->files() as $file) { + $class = trim(Str::replaceFirst($basePath, '', $file->getRealPath()), DIRECTORY_SEPARATOR); + + $command = str_replace( + [DIRECTORY_SEPARATOR, ucfirst(basename(app()->path())).'\\'], + ['\\', $namespace], + ucfirst(Str::replaceLast('.php', '', $class)), ); if (is_subclass_of($command, Command::class) && From 4f3f9d4f4bfb59ef42cfc0267030699c5cc316aa Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 2 Jun 2023 16:17:05 -0500 Subject: [PATCH 2/2] formatting --- src/Illuminate/Foundation/Console/Kernel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Console/Kernel.php b/src/Illuminate/Foundation/Console/Kernel.php index 77472eeaa74d..da77b1ab22e3 100644 --- a/src/Illuminate/Foundation/Console/Kernel.php +++ b/src/Illuminate/Foundation/Console/Kernel.php @@ -338,7 +338,7 @@ protected function load($paths) $class = trim(Str::replaceFirst($basePath, '', $file->getRealPath()), DIRECTORY_SEPARATOR); $command = str_replace( - [DIRECTORY_SEPARATOR, ucfirst(basename(app()->path())).'\\'], + [DIRECTORY_SEPARATOR, ucfirst(basename($this->app->path())).'\\'], ['\\', $namespace], ucfirst(Str::replaceLast('.php', '', $class)), );