Add withMiddlewares and withMiddlewaresAdded methods to the QueueInterface#279
Conversation
…rface and cover tests and stubs by Psalm
There was a problem hiding this comment.
Pull request overview
This PR aligns the public QueueInterface API with existing queue middleware override capabilities by adding withMiddlewares() and withMiddlewaresAdded(), and updates related decorators/stubs/tests while expanding Psalm coverage to stubs/ and tests/.
Changes:
- Add
withMiddlewares()/withMiddlewaresAdded()toQueueInterfaceand implement them inDebug\QueueDecorator, plus update test/stub implementations. - Expand Psalm analysis scope to include
stubs/andtests/, adding targeted suppressions where needed. - Misc test/benchmark maintenance (typing tweaks,
finaltest classes, JSON encoding strictness, PhpBench tag attribute removal).
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Unit/WorkerTest.php | Tighten param typing for Psalm (mixed). |
| tests/Unit/Stubs/StubAdapterTest.php | Update adapter callback signatures to match callable(MessageInterface): bool. |
| tests/Unit/Provider/PredefinedQueueProviderTest.php | Add Psalm suppression for intentional invalid argument case. |
| tests/Unit/Middleware/FailureHandling/Implementation/SendAgainMiddlewareTest.php | Mark test class final. |
| tests/Unit/Middleware/FailureHandling/Implementation/ExponentialDelayMiddlewareTest.php | Mark test class final. |
| tests/Unit/Middleware/CallableFactoryTest.php | Add Psalm suppression for redundant callable assertion. |
| tests/Unit/Message/JsonMessageSerializerTest.php | Use JSON_THROW_ON_ERROR for stricter JSON encoding in tests. |
| tests/Unit/Message/EnvelopeTest.php | Update DummyEnvelope instantiation to match its constructor. |
| tests/Unit/Debug/QueueProviderInterfaceProxyTest.php | Mark test class final. |
| tests/Unit/Debug/QueueDecoratorTest.php | Mark test class final. |
| tests/Unit/Debug/QueueCollectorTest.php | Adjust phpdoc + Psalm suppression for collector type narrowing. |
| tests/Unit/Cli/SignalLoopTest.php | Add Psalm suppressions around platform/extension-dependent constants/args. |
| tests/Benchmark/QueueBench.php | Remove PhpBench Tag usage/import. |
| tests/Benchmark/MetadataBench.php | Remove PhpBench Tag usage/import. |
| tests/App/StaticMessageHandler.php | Mark helper class final. |
| tests/App/FakeAdapter.php | Replace no-op methods with explicit exceptions (to satisfy analysis/return paths). |
| tests/App/DummyQueue.php | Add new QueueInterface methods to test dummy queue. |
| stubs/StubQueue.php | Add new QueueInterface methods to stub queue. |
| src/QueueInterface.php | Add withMiddlewares() and withMiddlewaresAdded() to the public interface. |
| src/Debug/QueueDecorator.php | Add the two middleware override methods to the decorator. |
| psalm.xml | Include stubs/ and tests/ in Psalm scope + suppress PropertyNotSetInConstructor for tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $instance = clone $this; | ||
| $instance->queue = $this->queue->withMiddlewares(...$middlewareDefinitions); | ||
|
|
||
| return $instance; | ||
| } | ||
|
|
||
| public function withMiddlewaresAdded(MiddlewarePushInterface|callable|array|string ...$middlewareDefinitions): self | ||
| { | ||
| $instance = clone $this; | ||
| $instance->queue = $this->queue->withMiddlewaresAdded(...$middlewareDefinitions); | ||
|
|
||
| return $instance; |
| /** | ||
| * Creates a new instance with the specified middlewares. All the existing middlewares are replaced. | ||
| * | ||
| * @param MiddlewarePushInterface|callable|array|string ...$middlewareDefinitions The middleware definitions. | ||
| */ | ||
| public function withMiddlewares(MiddlewarePushInterface|callable|array|string ...$middlewareDefinitions): self; | ||
|
|
||
| /** | ||
| * Creates a new instance with the specified middlewares added after the existing ones. | ||
| * | ||
| * @param MiddlewarePushInterface|callable|array|string ...$middlewareDefinitions The middleware definitions. | ||
| */ | ||
| public function withMiddlewaresAdded(MiddlewarePushInterface|callable|array|string ...$middlewareDefinitions): self; |
| $instance = clone $this; | ||
| $instance->queue = $this->queue->withMiddlewares(...$middlewareDefinitions); | ||
|
|
||
| return $instance; | ||
| } | ||
|
|
||
| public function withMiddlewaresAdded(MiddlewarePushInterface|callable|array|string ...$middlewareDefinitions): self | ||
| { | ||
| $instance = clone $this; | ||
| $instance->queue = $this->queue->withMiddlewaresAdded(...$middlewareDefinitions); | ||
|
|
||
| return $instance; |
…nd withMiddlewaresAdded
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #279 +/- ##
============================================
- Coverage 98.82% 98.38% -0.45%
- Complexity 314 321 +7
============================================
Files 47 47
Lines 854 868 +14
============================================
+ Hits 844 854 +10
- Misses 10 14 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
And cover tests and stubs with Psalm.