Repository: kbsali/php-redmine-api (php)

Issue:
Changes made in #257 introduces a BC break
Changes made in [#257](https://github.com/kbsali/php-redmine-api/pull/257/files#diff-a0d92f5dcb3b7fa15b6523c906ed0ad089ba350c1aa9d6cb36a011143fd246c8R66) introduces a BC break in the return value of [`AbstractApi::get()`](https://github.com/kbsali/php-redmine-api/pull/257/files#diff-a0d92f5dcb3b7fa15b6523c906ed0ad089ba350c1aa9d6cb36a011143fd246c8R47).
Prior to these changes, if the response body was empty, `get()` was returning `false`, and currently it returns `null`.
Since this package lacks a exception oriented flow in front of HTTP responses ending in error codes (400~599), my implementation relies in the return values to determine the situation about a request.

Obviously the compatibility with PSR-18 is great, I'd just like to expose this situation in order to verify if these changes could respect BC.
Note that this is the only one BC break I've checked, since this is the first issue I encountered after updating the dependency.

Pull request description:
Return `false` from `AbstractApi::get()` on empty response body
Fixes #274.

Patch:
diff --git a/src/Redmine/Api/AbstractApi.php b/src/Redmine/Api/AbstractApi.php
index 9aa1a0f..9303324 100644
--- a/src/Redmine/Api/AbstractApi.php
+++ b/src/Redmine/Api/AbstractApi.php
@@ -42,7 +42,7 @@ abstract class AbstractApi implements Api
      * @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 @@ abstract class AbstractApi implements Api
             }
         }
 
-        return ('' === $body) ? null : $body;
+        return ('' === $body) ? false : $body;
     }
 
     /**
diff --git a/src/Redmine/Api/IssueRelation.php b/src/Redmine/Api/IssueRelation.php
index a0fc1d1..bb6aa31 100644
--- a/src/Redmine/Api/IssueRelation.php
+++ b/src/Redmine/Api/IssueRelation.php
@@ -42,7 +42,7 @@ class IssueRelation extends AbstractApi
     public function show($id)
     {
         $ret = $this->get('/relations/'.urlencode($id).'.json');
-        if (null === $ret) {
+        if (false === $ret) {
             return [];
         }
 


Test patch:
diff --git a/tests/Unit/Api/AbstractApiTest.php b/tests/Unit/Api/AbstractApiTest.php
index d377f99..971e7b3 100644
--- a/tests/Unit/Api/AbstractApiTest.php
+++ b/tests/Unit/Api/AbstractApiTest.php
@@ -129,7 +129,8 @@ class AbstractApiTest extends TestCase
             ['{"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
         ];
     }