diff --git a/src/Internal/Delivery/Consumer.php b/src/Internal/Delivery/Consumer.php index c94afe6..1ec151d 100644 --- a/src/Internal/Delivery/Consumer.php +++ b/src/Internal/Delivery/Consumer.php @@ -14,7 +14,7 @@ */ final class Consumer { - /** @var array */ + /** @var array */ private array $consumers = []; public function __construct(DeliverySupervisor $supervisor) @@ -56,7 +56,7 @@ public function unregister(string $consumerTag): void public function cancelAll(callable $cancel): void { foreach (array_keys($this->consumers) as $consumerTag) { - $cancel($consumerTag); + $cancel((string) $consumerTag); } } } diff --git a/tests/ClientTest.php b/tests/ClientTest.php index f9667d6..b13a348 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -85,6 +85,24 @@ public function testConnectDisconnectOnDestructor(): void $channel->confirmSelect(); } + #[DoesNotPerformAssertions] + public function testNoCrashWhenDisconnectWithNumericConsumerTag(): void + { + $client = self::createClient(); + + $channel = $client->channel(); + $channel->queueDelete('events'); + $channel->queueDeclare('events', autoDelete: true); + + $channel->consume( + callback: static function (): void {}, + queue: 'events', + consumerTag: '1', + ); + + $client->disconnect(); + } + private static function createClient(): Client { return new Client(new Config(urls: ['rabbitmq:5672']));