From df85258c6c001c72f3b0bcdb1f75abd200db5a13 Mon Sep 17 00:00:00 2001 From: Michael Dyrynda Date: Tue, 17 Nov 2020 14:51:41 +1030 Subject: [PATCH] Update detection of closure-based scheduled tasks Use Str to check for empty commands, which will account for the command being null or an empty string. Also add check for the closure summaryForDisplay output being one of either `Closure` or `Callback`, which was added to support PHP 8 @see https://github.com/laravel/framework/pull/34999 --- src/TaskIdentifier.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/TaskIdentifier.php b/src/TaskIdentifier.php index 2e86530..3b84f19 100644 --- a/src/TaskIdentifier.php +++ b/src/TaskIdentifier.php @@ -19,11 +19,11 @@ class TaskIdentifier public function __invoke($task) { if ($task instanceof CallbackEvent) { - if (is_null($task->command) && $task->description && class_exists($task->description)) { + if (Str::of($task->command)->isEmpty() && $task->description && class_exists($task->description)) { return static::TYPE_JOB; } - if (is_null($task->command) && Str::is($task->description, $task->getSummaryForDisplay())) { + if (Str::of($task->command)->isEmpty() && Str::is($task->description, $task->getSummaryForDisplay())) { return static::TYPE_CLOSURE; } @@ -41,7 +41,7 @@ public function __invoke($task) } } - private function sanitisedCommand(string $command): string + private function sanitisedCommand(?string $command): string { return trim(str_replace([ "'",