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));