diff --git a/src/Redmine/Api/AbstractApi.php b/src/Redmine/Api/AbstractApi.php index 9aa1a0f1..93033245 100644 --- a/src/Redmine/Api/AbstractApi.php +++ b/src/Redmine/Api/AbstractApi.php @@ -42,7 +42,7 @@ public function lastCallFailed() * @param string $path * @param bool $decodeIfJson * - * @return string|array|SimpleXMLElement|null + * @return string|array|SimpleXMLElement|false */ protected function get($path, $decodeIfJson = true) { @@ -64,7 +64,7 @@ protected function get($path, $decodeIfJson = true) } } - return ('' === $body) ? null : $body; + return ('' === $body) ? false : $body; } /** diff --git a/src/Redmine/Api/IssueRelation.php b/src/Redmine/Api/IssueRelation.php index a0fc1d15..bb6aa31f 100644 --- a/src/Redmine/Api/IssueRelation.php +++ b/src/Redmine/Api/IssueRelation.php @@ -42,7 +42,7 @@ public function all($issueId, array $params = []) public function show($id) { $ret = $this->get('/relations/'.urlencode($id).'.json'); - if (null === $ret) { + if (false === $ret) { return []; } diff --git a/tests/Unit/Api/AbstractApiTest.php b/tests/Unit/Api/AbstractApiTest.php index d377f994..971e7b36 100644 --- a/tests/Unit/Api/AbstractApiTest.php +++ b/tests/Unit/Api/AbstractApiTest.php @@ -129,7 +129,8 @@ public function getJsonDecodingFromGetMethodData() ['{"foo_bar": 12345}', null, ['foo_bar' => 12345]], // test decode by default ['{"foo_bar": 12345}', false, '{"foo_bar": 12345}'], ['{"foo_bar": 12345}', true, ['foo_bar' => 12345]], - ['', true, null], // test decode with empty body + 'Empty body, JSON decode: false' => ['', false, false], + 'Empty body, JSON decode: true' => ['', true, false], ['{"foo_bar":', true, 'Error decoding body as JSON: Syntax error'], // test invalid JSON ]; }