Skip to content

Commit afa7ef7

Browse files
committed
comments
1 parent de43bf3 commit afa7ef7

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/Illuminate/Queue/Middleware/RetryIf.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@
88
class RetryIf
99
{
1010
/**
11-
* @param \Closure(\Throwable, ?mixed): bool $retryIf The condition of the failure that will retry the job.
11+
* A middleware that allows short-circuiting job retries. This does not
12+
* override the retry mechanism of the job and queue, so do not use
13+
* this middleware to extend tries beyond the those conditions.
14+
*
15+
* @param \Closure(\Throwable, mixed): bool $retryIf The truth-test callback to determine if the job should be retried or failed.
1216
*/
1317
public function __construct(protected Closure $retryIf)
1418
{
1519
}
1620

1721
/**
18-
* Do not retry if any of the exceptions were thrown.
22+
* Short-circuit retries if any of the exceptions were thrown.
1923
*
2024
* @param class-string<\Throwable> ...$exceptions
2125
* @return static
@@ -34,7 +38,7 @@ public static function failureIsNot(...$exceptions): static
3438
}
3539

3640
/**
37-
* Only retry if the exception thrown matches.
41+
* Continue retries for any of the specified exceptions.
3842
*
3943
* @param class-string<\Throwable> ...$exceptions
4044
* @return static

tests/Queue/RetryIfMiddlewareTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Orchestra\Testbench\TestCase;
1616
use PHPUnit\Framework\Attributes\DataProvider;
1717
use PHPUnit\Framework\Attributes\TestWith;
18+
use Throwable;
1819

1920
class RetryIfMiddlewareTest extends TestCase
2021
{
@@ -25,7 +26,7 @@ protected function setUp(): void
2526
}
2627

2728
/**
28-
* @return array<string, array{class-string<\Throwable>, RetryIf}>
29+
* @return array<string, array{class-string<\Throwable>, RetryIf, bool}>
2930
*/
3031
public static function expectedToFailDataProvider(): array
3132
{
@@ -71,7 +72,7 @@ public function test_middleware(
7172
'command' => serialize($job),
7273
]);
7374
$this->fail('Did not throw exception');
74-
} catch (\Throwable $e) {
75+
} catch (Throwable $e) {
7576
$this->assertInstanceOf($thrown, $e);
7677
}
7778

@@ -80,7 +81,7 @@ public function test_middleware(
8081

8182
#[TestWith(['abc', false])]
8283
#[TestWith(['tots', true])]
83-
public function test_can_test_against_job($value, bool $expectedToFail): void
84+
public function test_can_test_against_job_properties($value, bool $expectedToFail): void
8485
{
8586
RetryIfMiddlewareJob::$_middleware = [new RetryIf(fn ($thrown, $job) => $job->value === 'abc')];
8687

@@ -95,12 +96,11 @@ public function test_can_test_against_job($value, bool $expectedToFail): void
9596
'command' => serialize($job),
9697
]);
9798
$this->fail('Did not throw exception');
98-
} catch (\Throwable $e) {
99+
} catch (Throwable) {
99100
//
100101
}
101102

102103
$expectedToFail ? $job->assertFailed() : $job->assertNotFailed();
103-
104104
}
105105
}
106106

0 commit comments

Comments
 (0)