Skip to content

Commit

Permalink
ARCH-414 No need for the callback to have a nullable return param
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Namaka committed Nov 15, 2024
1 parent ec89ebc commit a6f7a11
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ public function testItReturnsTheDecodedMessageToTheHandlerInBlockingMode()
});

$receiver = new AmqpReceiver($connection, $serializer);
$receiver->pull(function (Envelope $envelope): ?bool {
$receiver->pull(function (Envelope $envelope): bool {
$this->assertEquals(new DummyMessage('Hi'), $envelope->getMessage());
return null;
return true;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function testReceivesMessagesInBlockingMode()
\call_user_func($callback, $amqpEnvelope, $amqpQueue);
});

$transport->pull(function (Envelope $envelope) use ($decodedMessage): ?bool {
$transport->pull(function (Envelope $envelope) use ($decodedMessage): bool {
$this->assertSame($decodedMessage, $envelope->getMessage());
return null;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,10 +468,10 @@ public function get(string $queueName): ?\AMQPEnvelope
/**
* Consume a message from the specified queue in blocking mode.
*
* @param ?callable(\AMQPEnvelope,\AMQPQueue):?bool $callback If callback return false, then processing thread will be
* returned from AMQPQueue::consume() to PHP script. If null is passed, then the messages delivered to this client
* will be made available to the first real callback registered. That allows one to have a single callback
* consuming from multiple queues.
* @param ?callable(\AMQPEnvelope,\AMQPQueue):bool $callback If callback return false, then processing thread will be
* returned from AMQPQueue::consume() to PHP script. If null is passed, then the messages delivered to this client
* will be made available to the first real callback registered. That allows one to have a single callback
* consuming from multiple queues.
*
* @throws \AMQPException
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
interface BlockingReceiverInterface extends ReceiverInterface
{
/**
* @param callable(\AMQPEnvelope):?bool $callback If callback return false, then processing thread will be
* @param callable(\AMQPEnvelope):bool $callback If callback return false, then processing thread will be
* returned to PHP script.
*
* @throws TransportException If there is an issue communicating with the transport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface QueueBlockingReceiverInterface extends BlockingReceiverInterface
* Pull messages from the specified queue names instead of consuming from all queues.
*
* @param string[] $queueNames
* @param callable(\AMQPEnvelope):?bool $callback If callback return false, then processing thread will be
* @param callable(\AMQPEnvelope):bool $callback If callback return false, then processing thread will be
* returned to PHP script.
*/
public function pullFromQueues(array $queueNames, callable $callback): void;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Messenger/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function run(array $options = []): void
$envelopeHandledStart = $this->clock->now();
foreach ($this->receivers as $transportName => $receiver) {
if ($blockingMode) {
$callback = function (Envelope $envelope) use ($transportName, &$envelopeHandled): ?bool {
$callback = function (Envelope $envelope) use ($transportName, &$envelopeHandled): bool {
$envelopeHandled = true;
$this->handleMessage($envelope, $transportName);

Expand Down

0 comments on commit a6f7a11

Please sign in to comment.