Skip to content

Commit

Permalink
Update Kernel::load() to use same classFromFile logic as events
Browse files Browse the repository at this point in the history
  • Loading branch information
calebdw committed Jun 2, 2023
1 parent 838bb1b commit 1a68b63
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Illuminate/Foundation/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) &&
Expand Down

0 comments on commit 1a68b63

Please sign in to comment.