diff --git a/src/RedisProxy.php b/src/RedisProxy.php index 0e2bc97..3149af7 100644 --- a/src/RedisProxy.php +++ b/src/RedisProxy.php @@ -807,14 +807,14 @@ public function rename(string $key, string $newKey): bool /** * Subscribes the client to the specified channels + * @param string|array ...$channels * @throws RedisProxyException */ - public function subscribe(...$channels): array + public function subscribe(callable $callback, ...$channels): array { $channels = $this->prepareArguments('subscribe', $channels); $this->init(); - return $this->driver->call('subscribe', [...$channels, function () { - }]); + return $this->driver->call('subscribe', [...$channels, $callback]); } /** diff --git a/tests/BaseDriverTest.php b/tests/BaseDriverTest.php index 08fd047..f4b393d 100644 --- a/tests/BaseDriverTest.php +++ b/tests/BaseDriverTest.php @@ -1352,17 +1352,20 @@ public function testRename():void self::assertTrue($this->redisProxy->rename('new_key', 'new_new_key')); } - public function testWrongRename(){ + public function testWrongRename() + { self::assertFalse($this->redisProxy->rename('my_keyaaa', 'new_key')); } - public function testEmptySubscribe(){ + public function testEmptySubscribe() + { $this->expectExceptionMessage("Error for command 'subscribe', use getPrevious() for more info"); $this->expectException(RedisProxyException::class); $this->redisProxy->subscribe(); } - public function testPublish(){ + public function testPublish() + { self::assertEquals(0, $this->redisProxy->publish('test', 'aaaa')); }