diff --git a/system/Format/FormatterInterface.php b/system/Format/FormatterInterface.php index 0c2492b90a77..5f6d6df3870a 100644 --- a/system/Format/FormatterInterface.php +++ b/system/Format/FormatterInterface.php @@ -21,7 +21,7 @@ interface FormatterInterface /** * Takes the given data and formats it. * - * @param array|object|string $data + * @param mixed $data * * @return false|non-empty-string */ diff --git a/system/Format/JSONFormatter.php b/system/Format/JSONFormatter.php index ac237fcc7af3..fb882a0e4eac 100644 --- a/system/Format/JSONFormatter.php +++ b/system/Format/JSONFormatter.php @@ -26,7 +26,7 @@ class JSONFormatter implements FormatterInterface /** * Takes the given data and formats it. * - * @param array|object|string $data + * @param mixed $data * * @return false|non-empty-string */ diff --git a/system/Format/XMLFormatter.php b/system/Format/XMLFormatter.php index efef70cec2cb..0f058e8a7ff7 100644 --- a/system/Format/XMLFormatter.php +++ b/system/Format/XMLFormatter.php @@ -27,7 +27,7 @@ class XMLFormatter implements FormatterInterface /** * Takes the given data and formats it. * - * @param array|object|string $data + * @param mixed $data * * @return false|non-empty-string */ diff --git a/system/HTTP/ResponseInterface.php b/system/HTTP/ResponseInterface.php index 258cbcf3c452..a1fbcb4acc06 100644 --- a/system/HTTP/ResponseInterface.php +++ b/system/HTTP/ResponseInterface.php @@ -200,7 +200,7 @@ public function setContentType(string $mime, string $charset = 'UTF-8'); /** * Converts the $body into JSON and sets the Content Type header. * - * @param array|object|string $body + * @param mixed $body * * @return $this */ @@ -218,7 +218,7 @@ public function getJSON(); /** * Converts $body into XML, and sets the correct Content-Type. * - * @param array|string $body + * @param mixed $body * * @return $this */ diff --git a/system/HTTP/ResponseTrait.php b/system/HTTP/ResponseTrait.php index 95e58b01a05d..50a8ab8c319e 100644 --- a/system/HTTP/ResponseTrait.php +++ b/system/HTTP/ResponseTrait.php @@ -169,7 +169,7 @@ public function setContentType(string $mime, string $charset = 'UTF-8') /** * Converts the $body into JSON and sets the Content Type header. * - * @param array|object|string $body + * @param mixed $body * * @return $this */ @@ -201,7 +201,7 @@ public function getJSON() /** * Converts $body into XML, and sets the correct Content-Type. * - * @param array|string $body + * @param mixed $body * * @return $this */ @@ -234,8 +234,8 @@ public function getXML() * Handles conversion of the data into the appropriate format, * and sets the correct Content-Type header for our response. * - * @param array|object|string $body - * @param string $format Valid: json, xml + * @param mixed $body + * @param string $format Valid: json, xml * * @return false|string * diff --git a/tests/system/Test/TestResponseTest.php b/tests/system/Test/TestResponseTest.php index 2ec981e786e5..c79104e43e72 100644 --- a/tests/system/Test/TestResponseTest.php +++ b/tests/system/Test/TestResponseTest.php @@ -314,7 +314,7 @@ public function testGetJSONEmptyJSON(): void public function testGetJSONFalseJSON(): void { $this->getTestResponse('

Hello World

'); - $this->response->setJSON(false, true); // @phpstan-ignore argument.type (Needed for testing) + $this->response->setJSON(false, true); // this should be FALSE - json_encode(false) $this->assertSame('false', $this->testResponse->getJSON()); @@ -323,7 +323,7 @@ public function testGetJSONFalseJSON(): void public function testGetJSONTrueJSON(): void { $this->getTestResponse('

Hello World

'); - $this->response->setJSON(true, true); // @phpstan-ignore argument.type (Needed for testing) + $this->response->setJSON(true, true); // this should be TRUE - json_encode(true) $this->assertSame('true', $this->testResponse->getJSON()); diff --git a/user_guide_src/source/changelogs/v4.7.5.rst b/user_guide_src/source/changelogs/v4.7.5.rst index b5f11bc83f79..787d67e7de9a 100644 --- a/user_guide_src/source/changelogs/v4.7.5.rst +++ b/user_guide_src/source/changelogs/v4.7.5.rst @@ -22,6 +22,8 @@ Message Changes Changes ******* +- **Response:** ``setJSON()`` and ``setXML()``, and the ``FormatterInterface::format()`` contract implemented by ``JSONFormatter`` and ``XMLFormatter``, now type their body/data parameter as ``mixed`` instead of ``array|object|string``, matching what they already accepted at runtime (e.g., scalars and ``bool``). + ************ Deprecations ************