From 6d19047079624394293f8bd5712693f0f6423c28 Mon Sep 17 00:00:00 2001 From: klimick Date: Mon, 8 Dec 2025 19:20:33 +0300 Subject: [PATCH 1/2] Fix crash when disconnect with numeric consumer tag --- src/Internal/Delivery/Consumer.php | 4 ++-- tests/ClientTest.php | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) 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..580f1ca 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -85,6 +85,25 @@ public function testConnectDisconnectOnDestructor(): void $channel->confirmSelect(); } + 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(); + + self::expectNotToPerformAssertions(); + } + private static function createClient(): Client { return new Client(new Config(urls: ['rabbitmq:5672'])); From d67f8bc208394bd75ea7510c41f9f3e327ad8b9b Mon Sep 17 00:00:00 2001 From: klimick Date: Sun, 14 Dec 2025 19:41:01 +0300 Subject: [PATCH 2/2] #[DoesNotPerformAssertions] --- tests/ClientTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 580f1ca..b13a348 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -85,6 +85,7 @@ public function testConnectDisconnectOnDestructor(): void $channel->confirmSelect(); } + #[DoesNotPerformAssertions] public function testNoCrashWhenDisconnectWithNumericConsumerTag(): void { $client = self::createClient(); @@ -100,8 +101,6 @@ public function testNoCrashWhenDisconnectWithNumericConsumerTag(): void ); $client->disconnect(); - - self::expectNotToPerformAssertions(); } private static function createClient(): Client