Upgrade to 3.8.0
This commit is contained in:
@@ -17,7 +17,7 @@ use Kirby\Filesystem\F;
|
||||
class Header
|
||||
{
|
||||
// configuration
|
||||
public static $codes = [
|
||||
public static array $codes = [
|
||||
|
||||
// successful
|
||||
'_200' => 'OK',
|
||||
@@ -56,9 +56,6 @@ class Header
|
||||
/**
|
||||
* Sends a content type header
|
||||
*
|
||||
* @param string $mime
|
||||
* @param string $charset
|
||||
* @param bool $send
|
||||
* @return string|void
|
||||
*/
|
||||
public static function contentType(string $mime, string $charset = 'UTF-8', bool $send = true)
|
||||
@@ -82,12 +79,8 @@ class Header
|
||||
|
||||
/**
|
||||
* Creates headers by key and value
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param string|null $value
|
||||
* @return string
|
||||
*/
|
||||
public static function create($key, string $value = null): string
|
||||
public static function create(string|array $key, string|null $value = null): string
|
||||
{
|
||||
if (is_array($key) === true) {
|
||||
$headers = [];
|
||||
@@ -106,9 +99,6 @@ class Header
|
||||
/**
|
||||
* Shortcut for static::contentType()
|
||||
*
|
||||
* @param string $mime
|
||||
* @param string $charset
|
||||
* @param bool $send
|
||||
* @return string|void
|
||||
*/
|
||||
public static function type(string $mime, string $charset = 'UTF-8', bool $send = true)
|
||||
@@ -123,11 +113,12 @@ class Header
|
||||
* and send a custom status code and message, use a $code string formatted
|
||||
* as 3 digits followed by a space and a message, e.g. '999 Custom Status'.
|
||||
*
|
||||
* @param int|string $code The HTTP status code
|
||||
* @param int|string|null $code The HTTP status code
|
||||
* @param bool $send If set to false the header will be returned instead
|
||||
* @return string|void
|
||||
* @psalm-return ($send is false ? string : void)
|
||||
*/
|
||||
public static function status($code = null, bool $send = true)
|
||||
public static function status(int|string|null $code = null, bool $send = true)
|
||||
{
|
||||
$codes = static::$codes;
|
||||
$protocol = Environment::getGlobally('SERVER_PROTOCOL', 'HTTP/1.1');
|
||||
@@ -154,7 +145,6 @@ class Header
|
||||
/**
|
||||
* Sends a 200 header
|
||||
*
|
||||
* @param bool $send
|
||||
* @return string|void
|
||||
*/
|
||||
public static function success(bool $send = true)
|
||||
@@ -165,7 +155,6 @@ class Header
|
||||
/**
|
||||
* Sends a 201 header
|
||||
*
|
||||
* @param bool $send
|
||||
* @return string|void
|
||||
*/
|
||||
public static function created(bool $send = true)
|
||||
@@ -176,7 +165,6 @@ class Header
|
||||
/**
|
||||
* Sends a 202 header
|
||||
*
|
||||
* @param bool $send
|
||||
* @return string|void
|
||||
*/
|
||||
public static function accepted(bool $send = true)
|
||||
@@ -187,7 +175,6 @@ class Header
|
||||
/**
|
||||
* Sends a 400 header
|
||||
*
|
||||
* @param bool $send
|
||||
* @return string|void
|
||||
*/
|
||||
public static function error(bool $send = true)
|
||||
@@ -198,7 +185,6 @@ class Header
|
||||
/**
|
||||
* Sends a 403 header
|
||||
*
|
||||
* @param bool $send
|
||||
* @return string|void
|
||||
*/
|
||||
public static function forbidden(bool $send = true)
|
||||
@@ -209,7 +195,6 @@ class Header
|
||||
/**
|
||||
* Sends a 404 header
|
||||
*
|
||||
* @param bool $send
|
||||
* @return string|void
|
||||
*/
|
||||
public static function notfound(bool $send = true)
|
||||
@@ -220,7 +205,6 @@ class Header
|
||||
/**
|
||||
* Sends a 404 header
|
||||
*
|
||||
* @param bool $send
|
||||
* @return string|void
|
||||
*/
|
||||
public static function missing(bool $send = true)
|
||||
@@ -231,7 +215,6 @@ class Header
|
||||
/**
|
||||
* Sends a 410 header
|
||||
*
|
||||
* @param bool $send
|
||||
* @return string|void
|
||||
*/
|
||||
public static function gone(bool $send = true)
|
||||
@@ -242,7 +225,6 @@ class Header
|
||||
/**
|
||||
* Sends a 500 header
|
||||
*
|
||||
* @param bool $send
|
||||
* @return string|void
|
||||
*/
|
||||
public static function panic(bool $send = true)
|
||||
@@ -253,7 +235,6 @@ class Header
|
||||
/**
|
||||
* Sends a 503 header
|
||||
*
|
||||
* @param bool $send
|
||||
* @return string|void
|
||||
*/
|
||||
public static function unavailable(bool $send = true)
|
||||
@@ -264,9 +245,6 @@ class Header
|
||||
/**
|
||||
* Sends a redirect header
|
||||
*
|
||||
* @param string $url
|
||||
* @param int $code
|
||||
* @param bool $send
|
||||
* @return string|void
|
||||
*/
|
||||
public static function redirect(string $url, int $code = 302, bool $send = true)
|
||||
@@ -288,7 +266,7 @@ class Header
|
||||
*
|
||||
* @param array $params Check out the defaults array for available parameters
|
||||
*/
|
||||
public static function download(array $params = [])
|
||||
public static function download(array $params = []): void
|
||||
{
|
||||
$defaults = [
|
||||
'name' => 'download',
|
||||
|
||||
Reference in New Issue
Block a user