update kirby

This commit is contained in:
isUnknown 2025-02-07 17:11:37 +01:00
parent 652262ac94
commit 9c662bcbba
165 changed files with 1757 additions and 598 deletions

View file

@ -508,7 +508,7 @@ class A
) {
$merged[] = $value;
// recursively merge the two array values
// recursively merge the two array values
} elseif (
is_array($value) === true &&
isset($merged[$key]) === true &&
@ -516,7 +516,7 @@ class A
) {
$merged[$key] = static::merge($merged[$key], $value, $mode);
// simply overwrite with the value from the second array
// simply overwrite with the value from the second array
} else {
$merged[$key] = $value;
}

View file

@ -198,7 +198,7 @@ class Collection extends Iterator implements Countable
* @param array|null $data
* @return array|$this
*/
public function data(array $data = null)
public function data(array|null $data = null)
{
if ($data === null) {
return $this->data;
@ -775,7 +775,7 @@ class Collection extends Iterator implements Countable
* @param bool $unique
* @return array
*/
public function pluck(string $field, string $split = null, bool $unique = false): array
public function pluck(string $field, string|null $split = null, bool $unique = false): array
{
$result = [];
@ -956,7 +956,7 @@ class Collection extends Iterator implements Countable
* @param int|null $limit The optional number of elements to return
* @return $this|static
*/
public function slice(int $offset = 0, int $limit = null)
public function slice(int $offset = 0, int|null $limit = null)
{
if ($offset === 0 && $limit === null) {
return $this;
@ -1027,7 +1027,7 @@ class Collection extends Iterator implements Countable
} elseif ($arg === SORT_DESC || $argLower === 'desc') {
$fields[$currentField]['direction'] = SORT_DESC;
// other string: the field name
// other string: the field name
} elseif (is_string($arg) === true) {
$values = [];
@ -1041,7 +1041,7 @@ class Collection extends Iterator implements Countable
$fields[] = ['field' => $arg, 'values' => $values];
// callable: custom field values
// callable: custom field values
} elseif (is_callable($arg) === true) {
$values = [];
@ -1055,7 +1055,7 @@ class Collection extends Iterator implements Countable
$fields[] = ['field' => null, 'values' => $values];
// flags
// flags
} else {
$fields[$currentField]['flags'] = $arg;
}
@ -1126,7 +1126,7 @@ class Collection extends Iterator implements Countable
* @param \Closure|null $map
* @return array
*/
public function toArray(Closure $map = null): array
public function toArray(Closure|null $map = null): array
{
if ($map !== null) {
return array_map($map, $this->data);
@ -1163,7 +1163,7 @@ class Collection extends Iterator implements Countable
* @param Closure|null $map
* @return array
*/
public function values(Closure $map = null): array
public function values(Closure|null $map = null): array
{
$data = $map === null ? $this->data : array_map($map, $this->data);
return array_values($data);
@ -1181,7 +1181,7 @@ class Collection extends Iterator implements Countable
* @param \Closure|null $fallback
* @return mixed
*/
public function when($condition, Closure $callback, Closure $fallback = null)
public function when($condition, Closure $callback, Closure|null $fallback = null)
{
if ($condition) {
return $callback->call($this, $condition);

View file

@ -23,7 +23,7 @@ abstract class Facade
/**
* Proxy for all public instance calls
*/
public static function __callStatic(string $method, array $args = null)
public static function __callStatic(string $method, array|null $args = null)
{
return static::instance()->$method(...$args);
}

View file

@ -405,7 +405,7 @@ class Html extends Xml
string $name,
array|string|null $content = '',
array $attr = [],
string $indent = null,
string|null $indent = null,
int $level = 0
): string {
// treat an explicit `null` value as an empty tag

View file

@ -78,7 +78,7 @@ class I18n
/**
* Formats a number
*/
public static function formatNumber(int|float $number, string $locale = null): string
public static function formatNumber(int|float $number, string|null $locale = null): string
{
$locale ??= static::locale();
$formatter = static::decimalNumberFormatter($locale);
@ -108,7 +108,7 @@ class I18n
*/
public static function template(
string $key,
string|array $fallback = null,
string|array|null $fallback = null,
array|null $replace = null,
string|null $locale = null
): string {
@ -130,8 +130,8 @@ class I18n
*/
public static function translate(
string|array|null $key,
string|array $fallback = null,
string $locale = null
string|array|null $fallback = null,
string|null $locale = null
): string|array|Closure|null {
// use current locale if no specific is passed
$locale ??= static::locale();
@ -242,7 +242,7 @@ class I18n
* by locale. If the translation does not exist
* yet, the loader will try to load it, if defined.
*/
public static function translation(string $locale = null): array
public static function translation(string|null $locale = null): array
{
$locale ??= static::locale();
@ -304,7 +304,7 @@ class I18n
public static function translateCount(
string $key,
int $count,
string $locale = null,
string|null $locale = null,
bool $formatNumber = true
) {
$locale ??= static::locale();

View file

@ -96,7 +96,7 @@ trait Properties
}
}
protected function setProperties($props, array $keys = null)
protected function setProperties($props, array|null $keys = null)
{
foreach (get_object_vars($this) as $name => $default) {
if ($name === 'propertyData') {

View file

@ -30,7 +30,7 @@ class Silo
return static::$data;
}
public static function get(string|array $key = null, $default = null)
public static function get(string|array|null $key = null, $default = null)
{
if ($key === null) {
return static::$data;
@ -42,7 +42,7 @@ class Silo
/**
* Removes an item from the data array
*/
public static function remove(string $key = null): array
public static function remove(string|null $key = null): array
{
// reset the entire array
if ($key === null) {

View file

@ -263,7 +263,7 @@ class Str
* Returns everything between two strings from the first occurrence of a given string
*/
public static function between(
string $string = null,
string|null $string,
string $start,
string $end
): string {
@ -275,7 +275,7 @@ class Str
*
* @param string $value The string to convert
*/
public static function camel(string $value = null): string
public static function camel(string|null $value = null): string
{
return lcfirst(static::studly($value));
}
@ -286,7 +286,7 @@ class Str
*
* @param string $value The string to convert
*/
public static function camelToKebab(string $value = null): string
public static function camelToKebab(string|null $value = null): string
{
return static::lower(preg_replace('!([a-z0-9])([A-Z])!', '$1-$2', $value));
}
@ -295,7 +295,7 @@ class Str
* Checks if a str contains another string
*/
public static function contains(
string $string = null,
string|null $string,
string $needle,
bool $caseInsensitive = false
): bool {
@ -316,7 +316,7 @@ class Str
*/
public static function date(
int|null $time = null,
string|IntlDateFormatter $format = null,
string|IntlDateFormatter|null $format = null,
string|null $handler = null
): string|int|false {
if (is_null($format) === true) {
@ -365,7 +365,7 @@ class Str
public static function convert(
string $string,
string $targetEncoding,
string $sourceEncoding = null
string|null $sourceEncoding = null
): string {
// detect the source encoding if not passed as third argument
$sourceEncoding ??= static::encoding($string);
@ -414,7 +414,7 @@ class Str
* Checks if a string ends with the passed needle
*/
public static function endsWith(
string $string = null,
string|null $string,
string $needle,
bool $caseInsensitive = false
): bool {
@ -574,7 +574,7 @@ class Str
/**
* Convert a string to kebab case.
*/
public static function kebab(string $value = null): string
public static function kebab(string|null $value = null): string
{
return static::snake($value, '-');
}
@ -582,7 +582,7 @@ class Str
/**
* Convert a kebab case string to camel case.
*/
public static function kebabToCamel(string $value = null): string
public static function kebabToCamel(string|null $value = null): string
{
return ucfirst(preg_replace_callback(
'/-(.)/',
@ -594,7 +594,7 @@ class Str
/**
* A UTF-8 safe version of strlen()
*/
public static function length(string $string = null): int
public static function length(string|null $string = null): int
{
return mb_strlen($string ?? '', 'UTF-8');
}
@ -602,7 +602,7 @@ class Str
/**
* A UTF-8 safe version of strtolower()
*/
public static function lower(string $string = null): string
public static function lower(string|null $string = null): string
{
return mb_strtolower($string ?? '', 'UTF-8');
}
@ -707,7 +707,7 @@ class Str
* @throws \Kirby\Exception\InvalidArgumentException for empty $needle
*/
public static function position(
string $string = null,
string|null $string,
string $needle,
bool $caseInsensitive = false
): int|false {
@ -739,7 +739,7 @@ class Str
* @param string $type Pool type (type of allowed characters)
*/
public static function random(
int $length = null,
int|null $length = null,
string $type = 'alphaNum'
): string|false {
$length ??= random_int(5, 10);
@ -967,7 +967,7 @@ class Str
* @return string The filled-in and partially escaped string
*/
public static function safeTemplate(
string $string = null,
string|null $string = null,
array $data = [],
array $options = []
): string {
@ -1024,7 +1024,7 @@ class Str
* @return string The shortened string
*/
public static function short(
string $string = null,
string|null $string = null,
int $length = 0,
string $appendix = '…'
): string {
@ -1129,9 +1129,9 @@ class Str
* @return string The safe string
*/
public static function slug(
string $string = null,
string $separator = null,
string $allowed = null,
string|null $string = null,
string|null $separator = null,
string|null $allowed = null,
int|false $maxlength = 128
): string {
$separator ??= static::$defaults['slug']['separator'];
@ -1176,7 +1176,7 @@ class Str
* Convert a string to snake case.
*/
public static function snake(
string $value = null,
string|null $value = null,
string $delimiter = '_'
): string {
if (ctype_lower($value) === false) {
@ -1230,7 +1230,7 @@ class Str
* Checks if a string starts with the passed needle
*/
public static function startsWith(
string $string = null,
string|null $string,
string $needle,
bool $caseInsensitive = false
): bool {
@ -1247,7 +1247,7 @@ class Str
*
* @param string $value The string to convert
*/
public static function studly(string $value = null): string
public static function studly(string|null $value = null): string
{
$value = str_replace(['-', '_'], ' ', $value);
$value = ucwords($value);
@ -1258,9 +1258,9 @@ class Str
* A UTF-8 safe version of substr()
*/
public static function substr(
string $string = null,
string|null $string = null,
int $start = 0,
int $length = null
int|null $length = null
): string {
return mb_substr($string ?? '', $start, $length, 'UTF-8');
}
@ -1287,7 +1287,7 @@ class Str
* @return string The filled-in string
*/
public static function template(
string $string = null,
string|null $string = null,
array $data = [],
array $options = []
): string {
@ -1384,7 +1384,7 @@ class Str
/**
* A UTF-8 safe version of ucfirst()
*/
public static function ucfirst(string $string = null): string
public static function ucfirst(string|null $string = null): string
{
$first = static::substr($string, 0, 1);
$rest = static::substr($string, 1);
@ -1394,7 +1394,7 @@ class Str
/**
* A UTF-8 safe version of ucwords()
*/
public static function ucwords(string $string = null): string
public static function ucwords(string|null $string = null): string
{
return mb_convert_case($string ?? '', MB_CASE_TITLE, 'UTF-8');
}
@ -1409,7 +1409,7 @@ class Str
*
* </code>
*/
public static function unhtml(string $string = null): string
public static function unhtml(string|null $string = null): string
{
return Html::decode($string);
}
@ -1434,7 +1434,7 @@ class Str
/**
* A UTF-8 safe version of strotoupper()
*/
public static function upper(string $string = null): string
public static function upper(string|null $string = null): string
{
return mb_strtoupper($string ?? '', 'UTF-8');
}
@ -1472,7 +1472,7 @@ class Str
* typographical widows at the end of a paragraph
* that's a single word in the last line
*/
public static function widont(string $string = null): string
public static function widont(string|null $string = null): string
{
// make sure $string is string
$string ??= '';
@ -1504,7 +1504,7 @@ class Str
public static function wrap(
string $string,
string $before,
string $after = null
string|null $after = null
): string {
return $before . $string . ($after ?? $before);
}

View file

@ -306,7 +306,7 @@ V::$validators = [
* Pass an operator as second argument and another date as
* third argument to compare them.
*/
'date' => function (string|null $value, string $operator = null, string $test = null): bool {
'date' => function (string|null $value, string|null $operator = null, string|null $test = null): bool {
// make sure $value is a string
$value ??= '';
@ -474,28 +474,28 @@ V::$validators = [
/**
* Checks if the number of characters in the value equals or is below the given maximum
*/
'maxLength' => function (string $value = null, $max): bool {
'maxLength' => function (string|null $value, $max): bool {
return Str::length(trim($value)) <= $max;
},
/**
* Checks if the number of characters in the value equals or is greater than the given minimum
*/
'minLength' => function (string $value = null, $min): bool {
'minLength' => function (string|null $value, $min): bool {
return Str::length(trim($value)) >= $min;
},
/**
* Checks if the number of words in the value equals or is below the given maximum
*/
'maxWords' => function (string $value = null, $max): bool {
'maxWords' => function (string|null $value, $max): bool {
return V::max(explode(' ', trim($value)), $max) === true;
},
/**
* Checks if the number of words in the value equals or is below the given maximum
*/
'minWords' => function (string $value = null, $min): bool {
'minWords' => function (string|null $value, $min): bool {
return V::min(explode(' ', trim($value)), $min) === true;
},
@ -628,7 +628,7 @@ V::$validators = [
/**
* Checks for a valid Uuid, optionally for specific model type
*/
'uuid' => function (string $value, string $type = null): bool {
'uuid' => function (string $value, string|null $type = null): bool {
return Uuid::is($value, $type);
}
];

View file

@ -373,7 +373,7 @@ class Xml
string $name,
array|string|null $content = '',
array $attr = [],
string $indent = null,
string|null $indent = null,
int $level = 0
): string {
$attr = static::attr($attr);