Skip to content

Commit 811cce7

Browse files
committed
minor symfony#52915 [Messenger] Fix missing @throws phpdoc on MiddlewareInterface, MessageBusInterface and SenderInterface (VincentLanglet)
This PR was submitted for the 5.4 branch but it was squashed and merged into the 7.1 branch instead. Discussion ---------- [Messenger] Fix missing ``@throws`` phpdoc on MiddlewareInterface, MessageBusInterface and SenderInterface | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes (kinda, it's missing phpdoc) | New feature? | no | Deprecations? | no | Issues | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead --> | License | MIT ``@throws`` phpdoc help the developper to know those methods can throw an exception and to have a contract about which exception can be thrown. I recently got an exception in production because of the call `$messageBus->dispatch()` without knowing it could throw an exception. Seems like it's because it iterable on every Middleware and a lot of middleware are throwing exception. As an example: - https://github.com/symfony/symfony/blob/7.1/src/Symfony/Component/Messenger/Middleware/RejectRedeliveredMessageMiddleware.php#L38 - Almost every sender are throwing `TransportException` in case of errors, which happen in the SendMessageMiddleware. Commits ------- 70a74b7 [Messenger] Fix missing ``@throws`` phpdoc on MiddlewareInterface, MessageBusInterface and SenderInterface
2 parents c71348a + 70a74b7 commit 811cce7

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

src/Symfony/Component/Messenger/MessageBusInterface.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Messenger;
1313

14+
use Symfony\Component\Messenger\Exception\ExceptionInterface;
1415
use Symfony\Component\Messenger\Stamp\StampInterface;
1516

1617
/**
@@ -23,6 +24,8 @@ interface MessageBusInterface
2324
*
2425
* @param object|Envelope $message The message or the message pre-wrapped in an envelope
2526
* @param StampInterface[] $stamps
27+
*
28+
* @throws ExceptionInterface
2629
*/
2730
public function dispatch(object $message, array $stamps = []): Envelope;
2831
}

src/Symfony/Component/Messenger/Middleware/MiddlewareInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@
1212
namespace Symfony\Component\Messenger\Middleware;
1313

1414
use Symfony\Component\Messenger\Envelope;
15+
use Symfony\Component\Messenger\Exception\ExceptionInterface;
1516

1617
/**
1718
* @author Samuel Roze <samuel.roze@gmail.com>
1819
*/
1920
interface MiddlewareInterface
2021
{
22+
/**
23+
* @throws ExceptionInterface
24+
*/
2125
public function handle(Envelope $envelope, StackInterface $stack): Envelope;
2226
}

src/Symfony/Component/Messenger/Transport/Sender/SenderInterface.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Messenger\Transport\Sender;
1313

1414
use Symfony\Component\Messenger\Envelope;
15+
use Symfony\Component\Messenger\Exception\ExceptionInterface;
1516

1617
/**
1718
* @author Samuel Roze <samuel.roze@gmail.com>
@@ -25,6 +26,8 @@ interface SenderInterface
2526
* like delivery delay.
2627
*
2728
* If applicable, the returned Envelope should contain a TransportMessageIdStamp.
29+
*
30+
* @throws ExceptionInterface
2831
*/
2932
public function send(Envelope $envelope): Envelope;
3033
}

0 commit comments

Comments
 (0)