From 38e90fc11b46a57394d2776e7eb732049dc25135 Mon Sep 17 00:00:00 2001 From: Luke Kuzmish Date: Fri, 10 Jan 2025 07:35:06 -0500 Subject: [PATCH 1/3] createPendingDispatch --- .../Foundation/Bus/Dispatchable.php | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/Illuminate/Foundation/Bus/Dispatchable.php b/src/Illuminate/Foundation/Bus/Dispatchable.php index 46b500559ff7..3fa3e76e3c74 100644 --- a/src/Illuminate/Foundation/Bus/Dispatchable.php +++ b/src/Illuminate/Foundation/Bus/Dispatchable.php @@ -16,7 +16,7 @@ trait Dispatchable */ public static function dispatch(...$arguments) { - return new PendingDispatch(new static(...$arguments)); + return static::createPendingDispatch(new static(...$arguments)); } /** @@ -32,12 +32,12 @@ public static function dispatchIf($boolean, ...$arguments) $dispatchable = new static(...$arguments); return value($boolean, $dispatchable) - ? new PendingDispatch($dispatchable) + ? static::createPendingDispatch($dispatchable) : new Fluent; } return value($boolean) - ? new PendingDispatch(new static(...$arguments)) + ? static::createPendingDispatch(new static(...$arguments)) : new Fluent; } @@ -53,13 +53,13 @@ public static function dispatchUnless($boolean, ...$arguments) if ($boolean instanceof Closure) { $dispatchable = new static(...$arguments); - return ! value($boolean, $dispatchable) - ? new PendingDispatch($dispatchable) + return !value($boolean, $dispatchable) + ? static::createPendingDispatch($dispatchable) : new Fluent; } - return ! value($boolean) - ? new PendingDispatch(new static(...$arguments)) + return !value($boolean) + ? static::createPendingDispatch(new static(...$arguments)) : new Fluent; } @@ -97,4 +97,15 @@ public static function withChain($chain) { return new PendingChain(static::class, $chain); } + + /** + * Prepare a pending job dispatch. + * + * @param mixed $job + * @return \Illuminate\Foundation\Bus\PendingDispatch + */ + protected static function createPendingDispatch($job) + { + return new PendingDispatch($job); + } } From 30b918e75f78d54feb3e0591aedd42cce2406ad7 Mon Sep 17 00:00:00 2001 From: Luke Kuzmish Date: Fri, 10 Jan 2025 08:53:55 -0500 Subject: [PATCH 2/3] clean up --- src/Illuminate/Foundation/Bus/Dispatchable.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Foundation/Bus/Dispatchable.php b/src/Illuminate/Foundation/Bus/Dispatchable.php index 3fa3e76e3c74..e206126dbef9 100644 --- a/src/Illuminate/Foundation/Bus/Dispatchable.php +++ b/src/Illuminate/Foundation/Bus/Dispatchable.php @@ -53,12 +53,12 @@ public static function dispatchUnless($boolean, ...$arguments) if ($boolean instanceof Closure) { $dispatchable = new static(...$arguments); - return !value($boolean, $dispatchable) + return ! value($boolean, $dispatchable) ? static::createPendingDispatch($dispatchable) : new Fluent; } - return !value($boolean) + return ! value($boolean) ? static::createPendingDispatch(new static(...$arguments)) : new Fluent; } From fc15b53514ab5cf7a16b9f0a746712a4c5ad39eb Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 10 Jan 2025 13:29:52 -0800 Subject: [PATCH 3/3] formatting --- src/Illuminate/Foundation/Bus/Dispatchable.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Illuminate/Foundation/Bus/Dispatchable.php b/src/Illuminate/Foundation/Bus/Dispatchable.php index e206126dbef9..1fef9872f833 100644 --- a/src/Illuminate/Foundation/Bus/Dispatchable.php +++ b/src/Illuminate/Foundation/Bus/Dispatchable.php @@ -16,7 +16,7 @@ trait Dispatchable */ public static function dispatch(...$arguments) { - return static::createPendingDispatch(new static(...$arguments)); + return static::newPendingDispatch(new static(...$arguments)); } /** @@ -32,12 +32,12 @@ public static function dispatchIf($boolean, ...$arguments) $dispatchable = new static(...$arguments); return value($boolean, $dispatchable) - ? static::createPendingDispatch($dispatchable) + ? static::newPendingDispatch($dispatchable) : new Fluent; } return value($boolean) - ? static::createPendingDispatch(new static(...$arguments)) + ? static::newPendingDispatch(new static(...$arguments)) : new Fluent; } @@ -54,12 +54,12 @@ public static function dispatchUnless($boolean, ...$arguments) $dispatchable = new static(...$arguments); return ! value($boolean, $dispatchable) - ? static::createPendingDispatch($dispatchable) + ? static::newPendingDispatch($dispatchable) : new Fluent; } return ! value($boolean) - ? static::createPendingDispatch(new static(...$arguments)) + ? static::newPendingDispatch(new static(...$arguments)) : new Fluent; } @@ -99,12 +99,12 @@ public static function withChain($chain) } /** - * Prepare a pending job dispatch. + * Create a new pending job dispatch instance. * * @param mixed $job * @return \Illuminate\Foundation\Bus\PendingDispatch */ - protected static function createPendingDispatch($job) + protected static function newPendingDispatch($job) { return new PendingDispatch($job); }