diff --git a/CHANGELOG.md b/CHANGELOG.md index a03f621..92e44ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased v2.x] +### Fixed + +- Allow Phpredis raw command to have 0 arguments ([Issue#39]) + ### Changed - (dev) Update version and rules of PHP-CS-Fixer and PHPStan @@ -196,6 +200,7 @@ First version [Issue#12]: https://github.com/MacFJA/php-redisearch/issues/12 [Issue#16]: https://github.com/MacFJA/php-redisearch/issues/16 [Issue#26]: https://github.com/MacFJA/php-redisearch/issues/26 +[Issue#39]: https://github.com/MacFJA/php-redisearch/issues/39 [PR#1]: https://github.com/MacFJA/php-redisearch/pull/1 [PR#3]: https://github.com/MacFJA/php-redisearch/pull/3 [PR#8]: https://github.com/MacFJA/php-redisearch/pull/8 diff --git a/src/Redis/Client/AmpRedisClient.php b/src/Redis/Client/AmpRedisClient.php index 659fbce..de3df2e 100644 --- a/src/Redis/Client/AmpRedisClient.php +++ b/src/Redis/Client/AmpRedisClient.php @@ -21,6 +21,7 @@ namespace MacFJA\RediSearch\Redis\Client; +use Amp\Promise; use function Amp\Promise\wait; use Amp\Redis\Redis; use function function_exists; @@ -50,14 +51,19 @@ public static function make($redis): Client public function execute(Command $command) { - $result = wait($this->redis->query($command->getId(), ...array_map('strval', $command->getArguments()))); + /** @var Promise $query */ + $query = $this->redis->query($command->getId(), ...array_map('strval', $command->getArguments())); + $result = wait($query); return $command->parseResponse($result); } public function executeRaw(...$args) { - return wait($this->redis->query(...array_map('strval', $args))); + /** @var Promise $query */ + $query = $this->redis->query(...array_map('strval', $args)); + + return wait($query); } public static function supports($redis): bool diff --git a/src/Redis/Client/PhpredisClient.php b/src/Redis/Client/PhpredisClient.php index fffb081..15194d3 100644 --- a/src/Redis/Client/PhpredisClient.php +++ b/src/Redis/Client/PhpredisClient.php @@ -49,9 +49,11 @@ public function execute(Command $command) { $arguments = $command->getArguments(); if (0 === count($arguments)) { - $arguments = [null]; + /** @psalm-suppress TooFewArguments */ + $rawResponse = $this->redis->rawCommand($command->getId()); + } else { + $rawResponse = $this->redis->rawCommand($command->getId(), ...$arguments); } - $rawResponse = $this->redis->rawCommand($command->getId(), ...$arguments); return $command->parseResponse($rawResponse); } @@ -74,9 +76,6 @@ public function executeRaw(...$args) if (count($args) < 1) { return null; } - if (count($args) < 2) { - $args[] = null; - } // @phpstan-ignore-next-line return $this->redis->rawCommand(...$args); }