From bbbba27bf7c10187853a006668c6e858dbaa2b9f Mon Sep 17 00:00:00 2001 From: Bilge Date: Sun, 28 Jul 2024 16:22:56 +0100 Subject: [PATCH] Fixed return type for RedistList::get(). Expanded allowed types for RedistList::get to include integer. --- src/Command/RedisList.php | 4 +++- test/Command/RedisListTest.php | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Command/RedisList.php b/src/Command/RedisList.php index 5488dd8..5f7ddb0 100644 --- a/src/Command/RedisList.php +++ b/src/Command/RedisList.php @@ -21,8 +21,10 @@ public function __construct( /** * @link https://redis.io/commands/lindex + * + * TODO: Change type declaration to int only in next major. */ - public function get(string $index): string + public function get(string|int $index): ?string { return $this->client->execute('lindex', $this->key, $index); } diff --git a/test/Command/RedisListTest.php b/test/Command/RedisListTest.php index 72d8238..e92f47e 100644 --- a/test/Command/RedisListTest.php +++ b/test/Command/RedisListTest.php @@ -51,6 +51,7 @@ public function test(): void $this->assertSame('y', $list->popHeadBlocking()); $this->assertSame('b', $list->popTailBlocking()); + $this->assertNull($this->redis->getList('nonexistent')->get(0)); $this->assertNull($this->redis->getList('nonexistent')->popHeadBlocking(1)); $this->assertNull($this->redis->getList('nonexistent')->popTailBlocking(1)); $this->assertNull($this->redis->getList('nonexistent')->popTailPushHeadBlocking('nonexistent', 1));