Skip to content

Commit e3c33d5

Browse files
AxaliaNtbolier
authored andcommitted
Fixed a PHP warning when trying to use count() on null
1 parent 2ee6b1d commit e3c33d5

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/Response/Cursor.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,13 @@ private function addResponse(ResponseInterface $response)
132132
{
133133
$this->index = 0;
134134
$this->isComplete = $response->getType() === ResponseType::SUCCESS_SEQUENCE;
135-
$this->size = $response->isAtomic() ? 1 : \count($response->getData());
135+
136+
if (\is_null($response->getData())) {
137+
$this->size = 0;
138+
} else {
139+
$this->size = $response->isAtomic() ? 1 : \count($response->getData());
140+
}
141+
136142
$this->response = $response;
137143
}
138144

src/Response/Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function getData()
8282
*/
8383
public function isAtomic(): bool
8484
{
85-
return \is_string($this->data) || \count($this->data) === 1;
85+
return \is_string($this->data) || (!\is_null($this->data) && \count($this->data) === 1);
8686
}
8787

8888
/**

0 commit comments

Comments
 (0)