Skip to content

Commit

Permalink
Merge pull request #19 from clue-labs/nullable
Browse files Browse the repository at this point in the history
Improve PHP 8.4+ support by avoiding implicitly nullable types
  • Loading branch information
clue authored Aug 6, 2024
2 parents 13e40f8 + 47a7b22 commit 9c78a04
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Clue/Redis/Protocol/Model/MultiBulkReply.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ class MultiBulkReply implements ModelInterface
* @param array|null $data
* @throws InvalidArgumentException
*/
public function __construct(array $data = null)
public function __construct($data = null)
{
if ($data !== null && !is_array($data)) { // manual type check to support legacy PHP < 7.1
throw new InvalidArgumentException('Argument #1 ($data) expected array|null');
}
$this->data = $data;
}

Expand Down
6 changes: 6 additions & 0 deletions tests/Model/MultiBulkReplyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ protected function createModel($value)
return new MultiBulkReply($value);
}

public function testConstructWithInvalidDataThrows()
{
$this->setExpectedException('InvalidArgumentException', 'Argument #1 ($data) expected array|null');
new MultiBulkReply('data');
}

public function testEmptyArray()
{
$model = $this->createModel(array());
Expand Down

0 comments on commit 9c78a04

Please sign in to comment.