Upgrade to 3.8.0

This commit is contained in:
Bastian Allgeier
2022-10-06 10:11:54 +02:00
parent a9ed4e45ca
commit 7d168aae58
332 changed files with 26337 additions and 21977 deletions

View File

@@ -19,9 +19,8 @@ class Cookie
{
/**
* Key to use for cookie signing
* @var string
*/
public static $key = 'KirbyHttpCookieKey';
public static string $key = 'KirbyHttpCookieKey';
/**
* Set a new cookie
@@ -68,7 +67,6 @@ class Cookie
* Calculates the lifetime for a cookie
*
* @param int $minutes Number of minutes or timestamp
* @return int
*/
public static function lifetime(int $minutes): int
{
@@ -120,9 +118,9 @@ class Cookie
* @param string|null $key The name of the cookie
* @param string|null $default The default value, which should be returned
* if the cookie has not been found
* @return mixed The found value
* @return string|array|null The found value
*/
public static function get(string $key = null, string $default = null)
public static function get(string|null $key = null, string|null $default = null): string|array|null
{
if ($key === null) {
return $_COOKIE;
@@ -137,9 +135,6 @@ class Cookie
/**
* Checks if a cookie exists
*
* @param string $key
* @return bool
*/
public static function exists(string $key): bool
{
@@ -149,9 +144,6 @@ class Cookie
/**
* Creates a HMAC for the cookie value
* Used as a cookie signature to prevent easy tampering with cookie data
*
* @param string $value
* @return string
*/
protected static function hmac(string $value): string
{
@@ -161,11 +153,8 @@ class Cookie
/**
* Parses the hashed value from a cookie
* and tries to extract the value
*
* @param string $string
* @return mixed
*/
protected static function parse(string $string)
protected static function parse(string $string): string|null
{
// if no hash-value separator is present, we can't parse the value
if (strpos($string, '+') === false) {
@@ -178,7 +167,7 @@ class Cookie
// if the hash or the value is missing at all return null
// $value can be an empty string, $hash can't be!
if (!is_string($hash) || $hash === '' || !is_string($value)) {
if ($hash === '') {
return null;
}
@@ -207,7 +196,7 @@ class Cookie
*/
public static function remove(string $key): bool
{
if (isset($_COOKIE[$key])) {
if (isset($_COOKIE[$key]) === true) {
unset($_COOKIE[$key]);
return setcookie($key, '', 1, '/') && setcookie($key, false);
}
@@ -221,9 +210,6 @@ class Cookie
* this ensures that the response is only cached for visitors who don't
* have this cookie set;
* https://github.com/getkirby/kirby/issues/4423#issuecomment-1166300526
*
* @param string $key
* @return void
*/
protected static function trackUsage(string $key): void
{