From ba674c6162ccb4f24c2e7a46ea51bce5b379e130 Mon Sep 17 00:00:00 2001 From: Jamie Date: Thu, 17 Mar 2022 00:05:30 +0000 Subject: [PATCH 1/3] Match schedule command name exactly. --- src/Illuminate/Console/Scheduling/ScheduleTestCommand.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php b/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php index 0e9001449e9b..196ca7450c92 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php @@ -2,6 +2,7 @@ namespace Illuminate\Console\Scheduling; +use Illuminate\Console\Application; use Illuminate\Console\Command; use Illuminate\Support\Str; @@ -51,7 +52,11 @@ public function handle(Schedule $schedule) } if (! empty($name = $this->option('name'))) { - $matches = array_filter($commandNames, fn ($commandName) => Str::endsWith($commandName, $name)); + $commandBinary = Application::phpBinary().' '.Application::artisanBinary(); + + $matches = array_filter($commandNames, function ($commandName) use ($commandBinary, $name) { + return trim(Str::replace($commandBinary, '', $commandName)) === $name; + }); if (count($matches) !== 1) { return $this->error('No matching scheduled command found.'); From 91e517370e1700629f7f2be252da0f0fe62cce0e Mon Sep 17 00:00:00 2001 From: Jamie Date: Thu, 17 Mar 2022 09:18:48 +0000 Subject: [PATCH 2/3] Fix Style CI. --- src/Illuminate/Console/Scheduling/ScheduleTestCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php b/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php index 196ca7450c92..04972e163d6d 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php @@ -55,7 +55,7 @@ public function handle(Schedule $schedule) $commandBinary = Application::phpBinary().' '.Application::artisanBinary(); $matches = array_filter($commandNames, function ($commandName) use ($commandBinary, $name) { - return trim(Str::replace($commandBinary, '', $commandName)) === $name; + return trim(Str::replace($commandBinary, '', $commandName)) === $name; }); if (count($matches) !== 1) { From b722497e08ebf55b667b6b17808bc01907f8e62f Mon Sep 17 00:00:00 2001 From: Jamie Date: Thu, 17 Mar 2022 15:38:40 +0000 Subject: [PATCH 3/3] Use str_replace() instead of Str::replace(). --- src/Illuminate/Console/Scheduling/ScheduleTestCommand.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php b/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php index 04972e163d6d..9fe44790c564 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleTestCommand.php @@ -4,7 +4,6 @@ use Illuminate\Console\Application; use Illuminate\Console\Command; -use Illuminate\Support\Str; class ScheduleTestCommand extends Command { @@ -55,7 +54,7 @@ public function handle(Schedule $schedule) $commandBinary = Application::phpBinary().' '.Application::artisanBinary(); $matches = array_filter($commandNames, function ($commandName) use ($commandBinary, $name) { - return trim(Str::replace($commandBinary, '', $commandName)) === $name; + return trim(str_replace($commandBinary, '', $commandName)) === $name; }); if (count($matches) !== 1) {