Skip to content

Commit a1e8cdc

Browse files
authored
Fixed return type for RedistList::get() (#96)
Expanded allowed types for RedistList::get to include integer.
1 parent 0b3f38d commit a1e8cdc

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Command/RedisList.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ public function __construct(
2121

2222
/**
2323
* @link https://redis.io/commands/lindex
24+
*
25+
* TODO: Change type declaration to int only in next major.
2426
*/
25-
public function get(string $index): string
27+
public function get(string|int $index): ?string
2628
{
2729
return $this->client->execute('lindex', $this->key, $index);
2830
}

test/Command/RedisListTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public function test(): void
5151
$this->assertSame('y', $list->popHeadBlocking());
5252
$this->assertSame('b', $list->popTailBlocking());
5353

54+
$this->assertNull($this->redis->getList('nonexistent')->get(0));
5455
$this->assertNull($this->redis->getList('nonexistent')->popHeadBlocking(1));
5556
$this->assertNull($this->redis->getList('nonexistent')->popTailBlocking(1));
5657
$this->assertNull($this->redis->getList('nonexistent')->popTailPushHeadBlocking('nonexistent', 1));

0 commit comments

Comments
 (0)