diff --git a/src/Illuminate/Queue/Console/WorkCommand.php b/src/Illuminate/Queue/Console/WorkCommand.php index 69b248d2b129..7785ec3cb615 100644 --- a/src/Illuminate/Queue/Console/WorkCommand.php +++ b/src/Illuminate/Queue/Console/WorkCommand.php @@ -115,7 +115,7 @@ public function handle() // connection being run for the queue operation currently being executed. $queue = $this->getQueue($connection); - if (! $this->hasOption('json') && Terminal::hasSttyAvailable()) { + if (! $this->outputUsingJson() && Terminal::hasSttyAvailable()) { $this->components->info( sprintf('Processing jobs from the [%s] %s.', $queue, str('queue')->plural(explode(',', $queue))) ); @@ -201,7 +201,7 @@ protected function listenForEvents() */ protected function writeOutput(Job $job, $status, Throwable $exception = null) { - $this->hasOption('json') + $this->outputUsingJson() ? $this->writeOutputAsJson($job, $status, $exception) : $this->writeOutputForCli($job, $status); } @@ -346,4 +346,18 @@ protected function downForMaintenance() { return $this->option('force') ? false : $this->laravel->isDownForMaintenance(); } + + /** + * Determine if the worker should output using JSON. + * + * @return bool + */ + protected function outputUsingJson() + { + if (! $this->hasOption('json')) { + return false; + } + + return $this->option('json'); + } } diff --git a/src/Illuminate/Support/ServiceProvider.php b/src/Illuminate/Support/ServiceProvider.php index 3edda126ed2a..466ece11c004 100755 --- a/src/Illuminate/Support/ServiceProvider.php +++ b/src/Illuminate/Support/ServiceProvider.php @@ -477,12 +477,12 @@ public function commands($commands) /** * Register commands that should run on "optimize" or "optimize:clear". * - * @param string $optimize - * @param string $clear + * @param string|null $optimize + * @param string|null $clear * @param string|null $key * @return void */ - protected function optimizes(string $optimize = null, string $clear = null, ?string $key = null) + protected function optimizes(?string $optimize = null, ?string $clear = null, ?string $key = null) { $key ??= (string) Str::of(get_class($this)) ->classBasename()