Skip to content

Add withMiddlewares and withMiddlewaresAdded methods to the QueueInterface#279

Merged
viktorprogger merged 4 commits intomasterfrom
with-middlewares-queue-interface
May 2, 2026
Merged

Add withMiddlewares and withMiddlewaresAdded methods to the QueueInterface#279
viktorprogger merged 4 commits intomasterfrom
with-middlewares-queue-interface

Conversation

@viktorprogger
Copy link
Copy Markdown
Contributor

@viktorprogger viktorprogger commented May 1, 2026

And cover tests and stubs with Psalm.

Q A
Is bugfix? ✔️
New feature?
Breaks BC? ✔️
Tests pass? ✔️
Fixed issues

@viktorprogger viktorprogger requested review from samdark and vjik May 1, 2026 20:20
@viktorprogger viktorprogger self-assigned this May 1, 2026
@viktorprogger viktorprogger added the status:code review The pull request needs review. label May 1, 2026
@samdark samdark requested a review from Copilot May 1, 2026 20:36
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() to QueueInterface and implement them in Debug\QueueDecorator, plus update test/stub implementations.
  • Expand Psalm analysis scope to include stubs/ and tests/, adding targeted suppressions where needed.
  • Misc test/benchmark maintenance (typing tweaks, final test 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.

Comment thread src/Debug/QueueDecorator.php Outdated
Comment on lines +51 to +62
$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;
Comment thread src/QueueInterface.php
Comment on lines +45 to +57
/**
* 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;
Comment thread src/Debug/QueueDecorator.php Outdated
Comment on lines +51 to +62
$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;
@codecov
Copy link
Copy Markdown

codecov Bot commented May 2, 2026

Codecov Report

❌ Patch coverage is 63.63636% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.38%. Comparing base (0a946f7) to head (c75c064).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/Debug/QueueDecorator.php 0.00% 4 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@viktorprogger viktorprogger merged commit 3af8d68 into master May 2, 2026
27 of 29 checks passed
@viktorprogger viktorprogger deleted the with-middlewares-queue-interface branch May 2, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:code review The pull request needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants