Upgrade to 4.2.0

This commit is contained in:
Bastian Allgeier
2024-04-10 11:09:52 +02:00
parent 77d9337371
commit 7f4eb7509d
88 changed files with 1187 additions and 490 deletions

View File

@@ -255,7 +255,7 @@ class A
* // result: ['cat' => 'miao', 'dog' => 'wuff'];
* </code>
*
* @param array $array The source array
* @param mixed $array The source array
* @param string|int|array|null $key The key to look for
* @param mixed $default Optional default value, which
* should be returned if no element
@@ -588,7 +588,7 @@ class A
*/
public static function prepend(array $array, array $prepend): array
{
return $prepend + $array;
return static::merge($prepend, $array, A::MERGE_APPEND);
}
/**

View File

@@ -107,16 +107,16 @@ class Date extends DateTime
static::validateUnit($unit);
$formats = [
'year' => 'Y-01-01P',
'month' => 'Y-m-01P',
'day' => 'Y-m-dP',
'hour' => 'Y-m-d H:00:00P',
'minute' => 'Y-m-d H:i:00P',
'second' => 'Y-m-d H:i:sP'
'year' => 'Y-01-01',
'month' => 'Y-m-01',
'day' => 'Y-m-d',
'hour' => 'Y-m-d H:00:00',
'minute' => 'Y-m-d H:i:00',
'second' => 'Y-m-d H:i:s'
];
$flooredDate = date($formats[$unit], $this->timestamp());
$this->set($flooredDate);
$flooredDate = $this->format($formats[$unit]);
$this->set($flooredDate, $this->timezone());
return $this;
}

View File

@@ -710,7 +710,7 @@ class Dom
return $options;
}
$options = array_merge([
return [
'allowedAttrPrefixes' => [],
'allowedAttrs' => true,
'allowedDataUris' => true,
@@ -724,11 +724,9 @@ class Dom
'doctypeCallback' => null,
'elementCallback' => null,
'urlAttrs' => ['href', 'src', 'xlink:href'],
], $options);
$options['_normalized'] = true;
return $options;
...$options,
'_normalized' => true
];
}
/**

View File

@@ -283,6 +283,14 @@ V::$validators = [
V::max($value, $max) === true;
},
/**
* Checks with the callback sent by the user
* It's ideal for one-time custom validations
*/
'callback' => function ($value, callable $callback): bool {
return $callback($value);
},
/**
* Checks if the given string contains the given value
*/