Upgrade to 4.0.0

This commit is contained in:
Bastian Allgeier
2023-11-28 09:33:56 +01:00
parent f96b96af76
commit 3b0b6546ca
480 changed files with 21371 additions and 13327 deletions

View File

@@ -20,68 +20,50 @@ class Responder
/**
* Timestamp when the response expires
* in Kirby's cache
*
* @var int|null
*/
protected $expires = null;
protected int|null $expires = null;
/**
* HTTP status code
*
* @var int
*/
protected $code = null;
protected int|null $code = null;
/**
* Response body
*
* @var string
*/
protected $body = null;
protected string|null $body = null;
/**
* Flag that defines whether the current
* response can be cached by Kirby's cache
*
* @var bool
*/
protected $cache = true;
protected bool $cache = true;
/**
* HTTP headers
*
* @var array
*/
protected $headers = [];
protected array $headers = [];
/**
* Content type
*
* @var string
*/
protected $type = null;
protected string|null $type = null;
/**
* Flag that defines whether the current
* response uses the HTTP `Authorization`
* request header
*
* @var bool
*/
protected $usesAuth = false;
protected bool $usesAuth = false;
/**
* List of cookie names the response
* relies on
*
* @var array
*/
protected $usesCookies = [];
protected array $usesCookies = [];
/**
* Creates and sends the response
*
* @return string
*/
public function __toString(): string
{
@@ -91,10 +73,9 @@ class Responder
/**
* Setter and getter for the response body
*
* @param string|null $body
* @return string|$this
* @return $this|string|null
*/
public function body(string $body = null)
public function body(string $body = null): static|string|null
{
if ($body === null) {
return $this->body;
@@ -110,10 +91,9 @@ class Responder
* by Kirby's cache
* @since 3.5.5
*
* @param bool|null $cache
* @return bool|$this
*/
public function cache(bool|null $cache = null)
public function cache(bool|null $cache = null): bool|static
{
if ($cache === null) {
// never ever cache private responses
@@ -134,10 +114,9 @@ class Responder
* `Authorization` request header
* @since 3.7.0
*
* @param bool|null $usesAuth
* @return bool|$this
*/
public function usesAuth(bool|null $usesAuth = null)
public function usesAuth(bool|null $usesAuth = null): bool|static
{
if ($usesAuth === null) {
return $this->usesAuth;
@@ -151,9 +130,6 @@ class Responder
* Setter for a cookie name that is
* used by the response
* @since 3.7.0
*
* @param string $name
* @return void
*/
public function usesCookie(string $name): void
{
@@ -168,7 +144,6 @@ class Responder
* names the response relies on
* @since 3.7.0
*
* @param array|null $usesCookies
* @return array|$this
*/
public function usesCookies(array|null $usesCookies = null)
@@ -233,7 +208,6 @@ class Responder
/**
* Setter and getter for the status code
*
* @param int|null $code
* @return int|$this
*/
public function code(int $code = null)
@@ -248,8 +222,6 @@ class Responder
/**
* Construct response from an array
*
* @param array $response
*/
public function fromArray(array $response): void
{
@@ -266,7 +238,6 @@ class Responder
/**
* Setter and getter for a single header
*
* @param string $key
* @param string|false|null $value
* @param bool $lazy If `true`, an existing header value is not overridden
* @return string|$this
@@ -293,7 +264,6 @@ class Responder
/**
* Setter and getter for all headers
*
* @param array|null $headers
* @return array|$this
*/
public function headers(array $headers = null)
@@ -333,7 +303,6 @@ class Responder
/**
* Shortcut to configure a json response
*
* @param array|null $json
* @return string|$this
*/
public function json(array $json = null)
@@ -348,12 +317,12 @@ class Responder
/**
* Shortcut to create a redirect response
*
* @param string|null $location
* @param int|null $code
* @return $this
*/
public function redirect(string|null $location = null, int|null $code = null)
{
public function redirect(
string|null $location = null,
int|null $code = null
) {
$location = Url::to($location ?? '/');
$location = Url::unIdn($location);
@@ -364,11 +333,8 @@ class Responder
/**
* Creates and returns the response object from the config
*
* @param string|null $body
* @return \Kirby\Cms\Response
*/
public function send(string $body = null)
public function send(string $body = null): Response
{
if ($body !== null) {
$this->body($body);
@@ -380,8 +346,6 @@ class Responder
/**
* Converts the response configuration
* to an array
*
* @return array
*/
public function toArray(): array
{
@@ -399,7 +363,6 @@ class Responder
/**
* Setter and getter for the content type
*
* @param string|null $type
* @return string|$this
*/
public function type(string $type = null)
@@ -423,10 +386,6 @@ class Responder
* is actually used/relied on by the response
* @since 3.7.0
* @internal
*
* @param bool $usesAuth
* @param array $usesCookies
* @return bool
*/
public static function isPrivate(bool $usesAuth, array $usesCookies): bool
{