update patch 1
This commit is contained in:
+3
-3
@@ -40,8 +40,8 @@ class JsonResponse extends Response
|
||||
{
|
||||
parent::__construct('', $status, $headers);
|
||||
|
||||
if ($json && !\is_string($data) && !is_numeric($data) && !\is_callable([$data, '__toString'])) {
|
||||
throw new \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)));
|
||||
if ($json && !\is_string($data) && !is_numeric($data) && !$data instanceof \Stringable) {
|
||||
throw new \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)));
|
||||
}
|
||||
|
||||
$data ??= new \ArrayObject();
|
||||
@@ -173,7 +173,7 @@ class JsonResponse extends Response
|
||||
// Not using application/javascript for compatibility reasons with older browsers.
|
||||
$this->headers->set('Content-Type', 'text/javascript');
|
||||
|
||||
return $this->setContent(sprintf('/**/%s(%s);', $this->callback, $this->data));
|
||||
return $this->setContent(\sprintf('/**/%s(%s);', $this->callback, $this->data));
|
||||
}
|
||||
|
||||
// Only set the header when there is none or when it equals 'text/javascript' (from a previous update with callback)
|
||||
|
||||
Reference in New Issue
Block a user