Skip to content

Commit 9c78a04

Browse files
authored
Merge pull request #19 from clue-labs/nullable
Improve PHP 8.4+ support by avoiding implicitly nullable types
2 parents 13e40f8 + 47a7b22 commit 9c78a04

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/Clue/Redis/Protocol/Model/MultiBulkReply.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ class MultiBulkReply implements ModelInterface
1919
* @param array|null $data
2020
* @throws InvalidArgumentException
2121
*/
22-
public function __construct(array $data = null)
22+
public function __construct($data = null)
2323
{
24+
if ($data !== null && !is_array($data)) { // manual type check to support legacy PHP < 7.1
25+
throw new InvalidArgumentException('Argument #1 ($data) expected array|null');
26+
}
2427
$this->data = $data;
2528
}
2629

tests/Model/MultiBulkReplyTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ protected function createModel($value)
1111
return new MultiBulkReply($value);
1212
}
1313

14+
public function testConstructWithInvalidDataThrows()
15+
{
16+
$this->setExpectedException('InvalidArgumentException', 'Argument #1 ($data) expected array|null');
17+
new MultiBulkReply('data');
18+
}
19+
1420
public function testEmptyArray()
1521
{
1622
$model = $this->createModel(array());

0 commit comments

Comments
 (0)