update lock clucknut
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 14s
Build, Push and Deploy / build-and-push (push) Successful in 3m14s
Build, Push and Deploy / deploy-staging (push) Successful in 25s
Build, Push and Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-04-18 20:32:18 +07:00
parent 4554035227
commit dcaf267458
3359 changed files with 153185 additions and 205489 deletions

View File

@@ -79,7 +79,7 @@ public static function &getRef(array &$array, string|int|array $key): mixed
* @template T2
* @param array<T1> $array1
* @param array<T2> $array2
* @return array<T1|T2>
* @return array<T1|T2|array<mixed>>
*/
public static function mergeTree(array $array1, array $array2): array
{
@@ -96,6 +96,7 @@ public static function mergeTree(array $array1, array $array2): array
/**
* Returns zero-indexed position of given array key. Returns null if key is not found.
* @param array<mixed> $array
*/
public static function getKeyOffset(array $array, string|int $key): ?int
{
@@ -104,9 +105,10 @@ public static function getKeyOffset(array $array, string|int $key): ?int
/**
* @param array<mixed> $array
* @deprecated use getKeyOffset()
*/
public static function searchKey(array $array, $key): ?int
public static function searchKey(array $array, string|int $key): ?int
{
return self::getKeyOffset($array, $key);
}
@@ -114,10 +116,11 @@ public static function searchKey(array $array, $key): ?int
/**
* Tests an array for the presence of value.
* @param array<mixed> $array
*/
public static function contains(array $array, mixed $value): bool
{
return in_array($value, $array, true);
return in_array($value, $array, strict: true);
}
@@ -125,9 +128,11 @@ public static function contains(array $array, mixed $value): bool
* Returns the first item (matching the specified predicate if given). If there is no such item, it returns result of invoking $else or null.
* @template K of int|string
* @template V
* @template E
* @param array<K, V> $array
* @param ?callable(V, K, array<K, V>): bool $predicate
* @return ?V
* @param ?callable(): E $else
* @return ($else is null ? ?V : V|E)
*/
public static function first(array $array, ?callable $predicate = null, ?callable $else = null): mixed
{
@@ -142,9 +147,11 @@ public static function first(array $array, ?callable $predicate = null, ?callabl
* Returns the last item (matching the specified predicate if given). If there is no such item, it returns result of invoking $else or null.
* @template K of int|string
* @template V
* @template E
* @param array<K, V> $array
* @param ?callable(V, K, array<K, V>): bool $predicate
* @return ?V
* @param ?callable(): E $else
* @return ($else is null ? ?V : V|E)
*/
public static function last(array $array, ?callable $predicate = null, ?callable $else = null): mixed
{
@@ -196,6 +203,8 @@ public static function lastKey(array $array, ?callable $predicate = null): int|s
/**
* Inserts the contents of the $inserted array into the $array immediately after the $key.
* If $key is null (or does not exist), it is inserted at the beginning.
* @param array<mixed> $array
* @param array<mixed> $inserted
*/
public static function insertBefore(array &$array, string|int|null $key, array $inserted): void
{
@@ -209,6 +218,8 @@ public static function insertBefore(array &$array, string|int|null $key, array $
/**
* Inserts the contents of the $inserted array into the $array before the $key.
* If $key is null (or does not exist), it is inserted at the end.
* @param array<mixed> $array
* @param array<mixed> $inserted
*/
public static function insertAfter(array &$array, string|int|null $key, array $inserted): void
{
@@ -224,6 +235,7 @@ public static function insertAfter(array &$array, string|int|null $key, array $i
/**
* Renames key in array.
* @param array<mixed> $array
*/
public static function renameKey(array &$array, string|int $oldKey, string|int $newKey): bool
{
@@ -260,6 +272,8 @@ public static function grep(
/**
* Transforms multidimensional array to flat array.
* @param array<mixed> $array
* @return array<mixed>
*/
public static function flatten(array $array, bool $preserveKeys = false): array
{
@@ -284,16 +298,18 @@ public static function isList(mixed $value): bool
/**
* Reformats table to associative tree. Path looks like 'field|field[]field->field=field'.
* @param string|string[] $path
* @param array<mixed> $array
* @param string|list<string> $path
* @return array<mixed>|\stdClass
*/
public static function associate(array $array, $path): array|\stdClass
public static function associate(array $array, string|array $path): array|\stdClass
{
$parts = is_array($path)
? $path
: preg_split('#(\[\]|->|=|\|)#', $path, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
if (!$parts || $parts === ['->'] || $parts[0] === '=' || $parts[0] === '|') {
throw new Nette\InvalidArgumentException("Invalid path '$path'.");
throw new Nette\InvalidArgumentException("Invalid path '" . (is_array($path) ? implode('', $path) : $path) . "'.");
}
$res = $parts[0] === '->' ? new \stdClass : [];
@@ -312,6 +328,8 @@ public static function associate(array $array, $path): array|\stdClass
$x = $row[$parts[$i]];
$row = null;
}
break; // '=' is always the final operation
} elseif ($part === '->') {
if (isset($parts[++$i])) {
if ($x === null) {
@@ -338,6 +356,8 @@ public static function associate(array $array, $path): array|\stdClass
/**
* Normalizes array to associative array. Replace numeric keys with their values, the new value will be $filling.
* @param array<mixed> $array
* @return array<string, mixed>
*/
public static function normalize(array $array, mixed $filling = null): array
{
@@ -481,8 +501,9 @@ public static function mapWithKeys(array $array, callable $transformer): array
/**
* Invokes all callbacks and returns array of results.
* @param callable[] $callbacks
* @return array<mixed>
*/
public static function invoke(iterable $callbacks, ...$args): array
public static function invoke(iterable $callbacks, mixed ...$args): array
{
$res = [];
foreach ($callbacks as $k => $cb) {
@@ -496,8 +517,9 @@ public static function invoke(iterable $callbacks, ...$args): array
/**
* Invokes method on every object in an array and returns array of results.
* @param object[] $objects
* @return array<mixed>
*/
public static function invokeMethod(iterable $objects, string $method, ...$args): array
public static function invokeMethod(iterable $objects, string $method, mixed ...$args): array
{
$res = [];
foreach ($objects as $k => $obj) {
@@ -511,6 +533,7 @@ public static function invokeMethod(iterable $objects, string $method, ...$args)
/**
* Copies the elements of the $array array to the $object object and then returns it.
* @template T of object
* @param iterable<mixed> $array
* @param T $object
* @return T
*/