Skip to content

Commit

Permalink
[10.x] Update Kernel::load() to use same classFromFile logic as eve…
Browse files Browse the repository at this point in the history
…nts (#47327)

* Update Kernel::load() to use same `classFromFile` logic as events

* formatting

---------

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
calebdw and taylorotwell authored Jun 2, 2023
1 parent cbc4a01 commit 2b174d5
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($this->app->path())).'\\'],
['\\', $namespace],
ucfirst(Str::replaceLast('.php', '', $class)),
);

if (is_subclass_of($command, Command::class) &&
Expand Down

0 comments on commit 2b174d5

Please sign in to comment.