Skip to content

Commit 72a267f

Browse files
committed
refactor: widen Response body and Formatter data typing to mixed
1 parent 9ec5138 commit 72a267f

8 files changed

Lines changed: 13 additions & 21 deletions

File tree

‎system/Format/FormatterInterface.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ interface FormatterInterface
2121
/**
2222
* Takes the given data and formats it.
2323
*
24-
* @param array<array-key, mixed>|object|string $data
24+
* @param mixed $data
2525
*
2626
* @return false|non-empty-string
2727
*/

‎system/Format/JSONFormatter.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class JSONFormatter implements FormatterInterface
2626
/**
2727
* Takes the given data and formats it.
2828
*
29-
* @param array<array-key, mixed>|object|string $data
29+
* @param mixed $data
3030
*
3131
* @return false|non-empty-string
3232
*/

‎system/Format/XMLFormatter.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class XMLFormatter implements FormatterInterface
2727
/**
2828
* Takes the given data and formats it.
2929
*
30-
* @param array<array-key, mixed>|object|string $data
30+
* @param mixed $data
3131
*
3232
* @return false|non-empty-string
3333
*/

‎system/HTTP/ResponseInterface.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public function setContentType(string $mime, string $charset = 'UTF-8');
200200
/**
201201
* Converts the $body into JSON and sets the Content Type header.
202202
*
203-
* @param array<array-key, mixed>|object|string $body
203+
* @param mixed $body
204204
*
205205
* @return $this
206206
*/
@@ -218,7 +218,7 @@ public function getJSON();
218218
/**
219219
* Converts $body into XML, and sets the correct Content-Type.
220220
*
221-
* @param array<array-key, mixed>|string $body
221+
* @param mixed $body
222222
*
223223
* @return $this
224224
*/

‎system/HTTP/ResponseTrait.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public function setContentType(string $mime, string $charset = 'UTF-8')
169169
/**
170170
* Converts the $body into JSON and sets the Content Type header.
171171
*
172-
* @param array<array-key, mixed>|object|string $body
172+
* @param mixed $body
173173
*
174174
* @return $this
175175
*/
@@ -201,7 +201,7 @@ public function getJSON()
201201
/**
202202
* Converts $body into XML, and sets the correct Content-Type.
203203
*
204-
* @param array<array-key, mixed>|string $body
204+
* @param mixed $body
205205
*
206206
* @return $this
207207
*/
@@ -234,8 +234,8 @@ public function getXML()
234234
* Handles conversion of the data into the appropriate format,
235235
* and sets the correct Content-Type header for our response.
236236
*
237-
* @param array<array-key, mixed>|object|string $body
238-
* @param string $format Valid: json, xml
237+
* @param mixed $body
238+
* @param string $format Valid: json, xml
239239
*
240240
* @return false|string
241241
*

‎user_guide_src/source/changelogs/v4.7.5.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Message Changes
2222
Changes
2323
*******
2424

25+
- **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``).
26+
2527
************
2628
Deprecations
2729
************

‎utils/phpstan-baseline/argument.type.neon‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 31 errors
1+
# total 29 errors
22

33
parameters:
44
ignoreErrors:
@@ -87,16 +87,6 @@ parameters:
8787
count: 1
8888
path: ../../tests/system/Test/FeatureTestTraitTest.php
8989

90-
-
91-
message: '#^Parameter \#1 \$body of method CodeIgniter\\HTTP\\Response\:\:setJSON\(\) expects array\<mixed\>\|object\|string, false given\.$#'
92-
count: 1
93-
path: ../../tests/system/Test/TestResponseTest.php
94-
95-
-
96-
message: '#^Parameter \#1 \$body of method CodeIgniter\\HTTP\\Response\:\:setJSON\(\) expects array\<mixed\>\|object\|string, true given\.$#'
97-
count: 1
98-
path: ../../tests/system/Test/TestResponseTest.php
99-
10090
-
10191
message: '#^Parameter \#2 \$context of method CodeIgniter\\View\\Parser\:\:setData\(\) expects ''attr''\|''css''\|''html''\|''js''\|''raw''\|''url''\|null, ''unknown'' given\.$#'
10292
count: 3

‎utils/phpstan-baseline/loader.neon‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 703 errors
1+
# total 701 errors
22

33
includes:
44
- argument.type.neon

0 commit comments

Comments
 (0)