From 3a12baa62db04cd72b1a6cb1cc8ad1bad2276e2d Mon Sep 17 00:00:00 2001 From: Mehmet Korkmaz Date: Sat, 20 Feb 2021 00:01:04 +0300 Subject: [PATCH] check if result is empty issue fixed --- src/ReJSON/Command/Get.php | 2 +- src/ReJSON/Command/GetArray.php | 2 +- tests/Module/ReJSONTest.php | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ReJSON/Command/Get.php b/src/ReJSON/Command/Get.php index 2ad42d0..05b8547 100644 --- a/src/ReJSON/Command/Get.php +++ b/src/ReJSON/Command/Get.php @@ -22,7 +22,7 @@ private function __construct( $this->arguments = [$key]; $this->arguments = array_merge($this->arguments, $paths); $this->responseCallback = function ($result) { - if ($result !== null) { + if (!empty($result)) { return json_decode($result); } return null; diff --git a/src/ReJSON/Command/GetArray.php b/src/ReJSON/Command/GetArray.php index 9a17aad..c935bf8 100644 --- a/src/ReJSON/Command/GetArray.php +++ b/src/ReJSON/Command/GetArray.php @@ -22,7 +22,7 @@ private function __construct( $this->arguments = [$key]; $this->arguments = array_merge($this->arguments, $paths); $this->responseCallback = function ($result) { - if ($result !== null) { + if (!empty($result)) { return json_decode($result, (bool) JSON_OBJECT_AS_ARRAY, 512, JSON_THROW_ON_ERROR); } return null; diff --git a/tests/Module/ReJSONTest.php b/tests/Module/ReJSONTest.php index 80b1d69..b13a7d9 100644 --- a/tests/Module/ReJSONTest.php +++ b/tests/Module/ReJSONTest.php @@ -174,7 +174,6 @@ public function shouldRunReJSONCommandMgetSuccessfully(): void $this->reJsonModule->set('test', '.baz', 'qux'); $this->reJsonModule->set('test', '.baz', 'quux', 'XX'); $this->reJsonModule->set('test2', '.', ['foo2' => 'bar2']); - var_dump($this->reJsonModule->mgetArray('test', 'test2', '.')); } /**