From c4cb6a073c35340d67432e46af53d61e91419320 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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/TaskIdentifier.php b/src/TaskIdentifier.php index 2e86530..09e2e67 100644 --- a/src/TaskIdentifier.php +++ b/src/TaskIdentifier.php @@ -19,15 +19,15 @@ 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; } - if (Str::is($task->getSummaryForDisplay(), 'Closure')) { + if (in_array($task->getSummaryForDisplay(), ['Closure', 'Callback'])) { 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([ "'",