From 09b6293cae46b2909928cbd34d89a105b69ec03c Mon Sep 17 00:00:00 2001 From: Albert Chen Date: Tue, 28 Oct 2025 12:26:53 +0800 Subject: [PATCH 1/4] fix: fix arguments of subscribe in redis connection --- src/core/src/Redis/RedisProxy.php | 32 ------------------------------- src/redis/src/RedisConnection.php | 27 +++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 35 deletions(-) delete mode 100644 src/core/src/Redis/RedisProxy.php diff --git a/src/core/src/Redis/RedisProxy.php b/src/core/src/Redis/RedisProxy.php deleted file mode 100644 index 718cc2e65..000000000 --- a/src/core/src/Redis/RedisProxy.php +++ /dev/null @@ -1,32 +0,0 @@ - $callback($message, $channel); - - parent::subscribe(Arr::wrap($channels), $callback); - } - - /** - * Subscribe to a set of given channels with wildcards. - */ - public function psubscribe(array|string $channels, Closure $callback): void - { - $callback = fn ($redis, $pattern, $channel, $message) => $callback($message, $channel); - - parent::psubscribe(Arr::wrap($channels), $callback); - } -} diff --git a/src/redis/src/RedisConnection.php b/src/redis/src/RedisConnection.php index efdba500c..31b59bdaa 100644 --- a/src/redis/src/RedisConnection.php +++ b/src/redis/src/RedisConnection.php @@ -5,6 +5,7 @@ namespace Hypervel\Redis; use Hyperf\Redis\RedisConnection as HyperfRedisConnection; +use Hypervel\Support\Arr; use Hypervel\Support\Collection; use Redis; use Throwable; @@ -157,7 +158,7 @@ * @method static \Redis|bool pfmerge(string $dst, array $srckeys) * @method static \Redis|string|bool ping(string|null $message = null) * @method static \Redis|bool psetex(string $key, int $expire, mixed $value) - * @method static bool psubscribe(array $patterns, callable $cb) + * @method static void psubscribe(array|string $channels, Closure $callback) * @method static \Redis|int|false pttl(string $key) * @method static \Redis|int|false publish(string $channel, string $message) * @method static mixed pubsub(string $command, mixed $arg = null) @@ -202,7 +203,7 @@ * @method static \Redis|int|false srem(string $key, mixed $value, mixed ...$other_values) * @method static bool ssubscribe(array $channels, callable $cb) * @method static \Redis|int|false strlen(string $key) - * @method static bool subscribe(array $channels, callable $cb) + * @method static void subscribe(array|string $channels, Closure $callback) * @method static \Redis|array|bool sunsubscribe(array $channels) * @method static \Redis|bool swapdb(int $src, int $dst) * @method static \Redis|array time() @@ -683,11 +684,31 @@ protected function callSubscribe(string $name, array $arguments): mixed $this->connection->setOption(Redis::OPT_READ_TIMEOUT, -1); try { - return $this->connection->{$name}(...$arguments); + return $this->connection->{$name}( + ...$this->getSubscribeArguments($name, $arguments) + ); } finally { // Restore the read timeout to the original value before // returning to the connection pool. $this->connection->setOption(Redis::OPT_READ_TIMEOUT, $timeout); } } + + protected function getSubscribeArguments(string $name, array $arguments): array + { + $channels = Arr::wrap($arguments[0]); + $callback = $arguments[1]; + + if ($name === 'subscribe') { + return [ + $channels, + fn ($redis, $channel, $message) => $callback($message, $channel), + ]; + } + + return [ + $channels, + $callback = fn ($redis, $pattern, $channel, $message) => $callback($message, $channel) + ]; + } } From cf6ba4a2e4cd8bfd8d9555d3d3b68c201e1c01c1 Mon Sep 17 00:00:00 2001 From: Albert Chen Date: Tue, 28 Oct 2025 12:28:49 +0800 Subject: [PATCH 2/4] fix: fix php-cs --- src/redis/src/RedisConnection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/redis/src/RedisConnection.php b/src/redis/src/RedisConnection.php index 31b59bdaa..a0a026d89 100644 --- a/src/redis/src/RedisConnection.php +++ b/src/redis/src/RedisConnection.php @@ -708,7 +708,7 @@ protected function getSubscribeArguments(string $name, array $arguments): array return [ $channels, - $callback = fn ($redis, $pattern, $channel, $message) => $callback($message, $channel) + $callback = fn ($redis, $pattern, $channel, $message) => $callback($message, $channel), ]; } } From d0505b67bce07b5a60ea5b98aed613669b1220cb Mon Sep 17 00:00:00 2001 From: Albert Chen Date: Tue, 28 Oct 2025 13:33:26 +0800 Subject: [PATCH 3/4] chore: update phpdocs in redis facade --- src/support/src/Facades/Redis.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/support/src/Facades/Redis.php b/src/support/src/Facades/Redis.php index b07d1e49f..eb6674403 100644 --- a/src/support/src/Facades/Redis.php +++ b/src/support/src/Facades/Redis.php @@ -171,7 +171,7 @@ * @method static \Redis|bool pfmerge(string $dst, array $srckeys) * @method static \Redis|string|bool ping(string|null $message = null) * @method static \Redis|bool psetex(string $key, int $expire, mixed $value) - * @method static bool psubscribe(array $patterns, callable $cb) + * @method static void psubscribe(array|string $channels, Closure $callback) * @method static \Redis|int|false pttl(string $key) * @method static \Redis|int|false publish(string $channel, string $message) * @method static mixed pubsub(string $command, mixed $arg = null) @@ -216,7 +216,7 @@ * @method static \Redis|int|false srem(string $key, mixed $value, mixed ...$other_values) * @method static bool ssubscribe(array $channels, callable $cb) * @method static \Redis|int|false strlen(string $key) - * @method static bool subscribe(array $channels, callable $cb) + * @method static void subscribe(array|string $channels, Closure $callback) * @method static \Redis|array|bool sunsubscribe(array $channels) * @method static \Redis|bool swapdb(int $src, int $dst) * @method static \Redis|array time() From a72b342c87473a8e90ee452d78c2728573d571fd Mon Sep 17 00:00:00 2001 From: Albert Chen Date: Tue, 28 Oct 2025 13:41:00 +0800 Subject: [PATCH 4/4] fix: fix phpstan --- src/redis/src/RedisConnection.php | 4 ++-- src/support/src/Facades/Queue.php | 6 ++++++ src/support/src/Facades/Redis.php | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/redis/src/RedisConnection.php b/src/redis/src/RedisConnection.php index a0a026d89..9570e7b0e 100644 --- a/src/redis/src/RedisConnection.php +++ b/src/redis/src/RedisConnection.php @@ -158,7 +158,7 @@ * @method static \Redis|bool pfmerge(string $dst, array $srckeys) * @method static \Redis|string|bool ping(string|null $message = null) * @method static \Redis|bool psetex(string $key, int $expire, mixed $value) - * @method static void psubscribe(array|string $channels, Closure $callback) + * @method static void psubscribe(array|string $channels, \Closure $callback) * @method static \Redis|int|false pttl(string $key) * @method static \Redis|int|false publish(string $channel, string $message) * @method static mixed pubsub(string $command, mixed $arg = null) @@ -203,7 +203,7 @@ * @method static \Redis|int|false srem(string $key, mixed $value, mixed ...$other_values) * @method static bool ssubscribe(array $channels, callable $cb) * @method static \Redis|int|false strlen(string $key) - * @method static void subscribe(array|string $channels, Closure $callback) + * @method static void subscribe(array|string $channels, \Closure $callback) * @method static \Redis|array|bool sunsubscribe(array $channels) * @method static \Redis|bool swapdb(int $src, int $dst) * @method static \Redis|array time() diff --git a/src/support/src/Facades/Queue.php b/src/support/src/Facades/Queue.php index d29f70540..b3c22d71a 100644 --- a/src/support/src/Facades/Queue.php +++ b/src/support/src/Facades/Queue.php @@ -34,6 +34,10 @@ * @method static array getPoolables() * @method static \Hypervel\Queue\QueueManager setPoolables(array $poolables) * @method static int size(string|null $queue = null) + * @method static int pendingSize(string|null $queue = null) + * @method static int delayedSize(string|null $queue = null) + * @method static int reservedSize(string|null $queue = null) + * @method static int|null creationTimeOfOldestPendingJob(string|null $queue = null) * @method static mixed push(object|string $job, mixed $data = '', string|null $queue = null) * @method static mixed pushOn(string|null $queue, object|string $job, mixed $data = '') * @method static mixed pushRaw(string $payload, string|null $queue = null, array $options = []) @@ -47,6 +51,8 @@ * @method static mixed getJobBackoff(mixed $job) * @method static mixed getJobExpiration(mixed $job) * @method static void createPayloadUsing(callable|null $callback) + * @method static array getConfig() + * @method static \Hypervel\Queue\Queue setConfig(array $config) * @method static \Psr\Container\ContainerInterface getContainer() * @method static \Hypervel\Queue\Queue setContainer(\Psr\Container\ContainerInterface $container) * @method static \Hypervel\Support\Testing\Fakes\QueueFake except(array|string $jobsToBeQueued) diff --git a/src/support/src/Facades/Redis.php b/src/support/src/Facades/Redis.php index eb6674403..ed557cb6d 100644 --- a/src/support/src/Facades/Redis.php +++ b/src/support/src/Facades/Redis.php @@ -171,7 +171,7 @@ * @method static \Redis|bool pfmerge(string $dst, array $srckeys) * @method static \Redis|string|bool ping(string|null $message = null) * @method static \Redis|bool psetex(string $key, int $expire, mixed $value) - * @method static void psubscribe(array|string $channels, Closure $callback) + * @method static void psubscribe(array|string $channels, \Closure $callback) * @method static \Redis|int|false pttl(string $key) * @method static \Redis|int|false publish(string $channel, string $message) * @method static mixed pubsub(string $command, mixed $arg = null) @@ -216,7 +216,7 @@ * @method static \Redis|int|false srem(string $key, mixed $value, mixed ...$other_values) * @method static bool ssubscribe(array $channels, callable $cb) * @method static \Redis|int|false strlen(string $key) - * @method static void subscribe(array|string $channels, Closure $callback) + * @method static void subscribe(array|string $channels, \Closure $callback) * @method static \Redis|array|bool sunsubscribe(array $channels) * @method static \Redis|bool swapdb(int $src, int $dst) * @method static \Redis|array time()