You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* 4.4:
[HttpFoundation] Fix TypeError: Argument 1 passed to JsonResponse::setJson() must be of the type string, object given
[Security][Validator] Add missing Portuguese translations
Add Croatian (hr) translations
Copy file name to clipboardExpand all lines: JsonResponse.php
+8-4Lines changed: 8 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -43,6 +43,10 @@ public function __construct($data = null, int $status = 200, array $headers = []
43
43
{
44
44
parent::__construct('', $status, $headers);
45
45
46
+
if ($json && !\is_string($data) && !is_numeric($data) && !\is_callable([$data, '__toString'])) {
47
+
thrownew \TypeError(sprintf('"%s": If $json is set to true, argument $data must be a string or object implementing __toString(), "%s" given.', __METHOD__, get_debug_type($data)));
48
+
}
49
+
46
50
if (null === $data) {
47
51
$data = new \ArrayObject();
48
52
}
@@ -81,13 +85,13 @@ public static function create($data = null, int $status = 200, array $headers =
0 commit comments