Upgrade to 3.9.1

This commit is contained in:
Bastian Allgeier
2023-01-31 11:10:44 +01:00
parent 6e5c9d1f48
commit c58864a585
54 changed files with 633 additions and 465 deletions

View File

@@ -50,8 +50,13 @@ class Response
/**
* Creates a new response object
*/
public function __construct(string|array $body = '', string|null $type = null, int|null $code = null, array|null $headers = null, string|null $charset = null)
{
public function __construct(
string|array $body = '',
string|null $type = null,
int|null $code = null,
array|null $headers = null,
string|null $charset = null
) {
// array construction
if (is_array($body) === true) {
$params = $body;
@@ -127,8 +132,11 @@ class Response
*
* @param array $props Custom overrides for response props (e.g. headers)
*/
public static function download(string $file, string|null $filename = null, array $props = []): static
{
public static function download(
string $file,
string|null $filename = null,
array $props = []
): static {
if (file_exists($file) === false) {
throw new Exception('The file could not be found');
}
@@ -224,8 +232,12 @@ class Response
* Creates a json response with appropriate
* header and automatic conversion of arrays.
*/
public static function json(string|array $body = '', int|null $code = null, bool|null $pretty = null, array $headers = []): static
{
public static function json(
string|array $body = '',
int|null $code = null,
bool|null $pretty = null,
array $headers = []
): static {
if (is_array($body) === true) {
$body = json_encode($body, $pretty === true ? JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES : 0);
}