diff --git a/src/Illuminate/Console/Scheduling/ScheduleListCommand.php b/src/Illuminate/Console/Scheduling/ScheduleListCommand.php index 06a677845700..e86839f25e61 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleListCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleListCommand.php @@ -52,6 +52,7 @@ public function handle(Schedule $schedule) $expression = $this->formatCronExpression($event->expression, $expressionSpacing); $command = $event->command; + $description = $event->description; if (! $this->output->isVerbose()) { $command = str_replace( @@ -62,7 +63,12 @@ public function handle(Schedule $schedule) } if ($event instanceof CallbackEvent) { - $command = 'Closure at: '.$this->getClosureLocation($event); + if (class_exists($event->description)) { + $command = $event->description; + $description = ''; + } else { + $command = 'Closure at: '.$this->getClosureLocation($event); + } } $command = mb_strlen($command) > 1 ? "{$command} " : ''; @@ -95,11 +101,11 @@ public function handle(Schedule $schedule) $hasMutex, $nextDueDateLabel, $nextDueDate - ), $this->output->isVerbose() && mb_strlen($event->description) > 1 ? sprintf( + ), $this->output->isVerbose() && mb_strlen($description) > 1 ? sprintf( ' %s%s %s', str_repeat(' ', mb_strlen($expression) + 2), '⇁', - $event->description + $description ) : '']; }); diff --git a/tests/Integration/Console/Scheduling/ScheduleListCommandTest.php b/tests/Integration/Console/Scheduling/ScheduleListCommandTest.php index 86b5182ab7c4..eed124db3270 100644 --- a/tests/Integration/Console/Scheduling/ScheduleListCommandTest.php +++ b/tests/Integration/Console/Scheduling/ScheduleListCommandTest.php @@ -26,6 +26,7 @@ public function testDisplaySchedule() $this->schedule->command(FooCommand::class)->quarterly(); $this->schedule->command('inspire')->twiceDaily(14, 18); $this->schedule->command('foobar', ['a' => 'b'])->everyMinute(); + $this->schedule->job(FooJob::class)->everyMinute(); $this->schedule->call(fn () => '')->everyMinute(); $closureLineNumber = __LINE__ - 1; @@ -36,6 +37,7 @@ public function testDisplaySchedule() ->expectsOutput(' 0 0 1 1-12/3 * php artisan foo:command .... Next Due: 3 months from now') ->expectsOutput(' 0 14,18 * * * php artisan inspire ........ Next Due: 14 hours from now') ->expectsOutput(' * * * * * php artisan foobar a='.ProcessUtils::escapeArgument('b').' ... Next Due: 1 minute from now') + ->expectsOutput(' * * * * * Illuminate\Tests\Integration\Console\Scheduling\FooJob Next Due: 1 minute from now') ->expectsOutput(' * * * * * Closure at: '.$closureFilePath.':'.$closureLineNumber.' Next Due: 1 minute from now'); } @@ -65,3 +67,7 @@ class FooCommand extends Command protected $description = 'This is the description of the command.'; } + +class FooJob +{ +}