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

@@ -22,6 +22,7 @@ final class Iterables
/**
* Tests for the presence of value.
* @param iterable<mixed> $iterable
*/
public static function contains(iterable $iterable, mixed $value): bool
{
@@ -36,6 +37,7 @@ public static function contains(iterable $iterable, mixed $value): bool
/**
* Tests for the presence of key.
* @param iterable<mixed> $iterable
*/
public static function containsKey(iterable $iterable, mixed $key): bool
{
@@ -52,9 +54,11 @@ public static function containsKey(iterable $iterable, mixed $key): 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
* @template V
* @template E
* @param iterable<K, V> $iterable
* @param ?callable(V, K, iterable<K, V>): bool $predicate
* @return ?V
* @param ?callable(): E $else
* @return ($else is null ? ?V : V|E)
*/
public static function first(iterable $iterable, ?callable $predicate = null, ?callable $else = null): mixed
{
@@ -71,9 +75,11 @@ public static function first(iterable $iterable, ?callable $predicate = null, ?c
* Returns the key of first item (matching the specified predicate if given). If there is no such item, it returns result of invoking $else or null.
* @template K
* @template V
* @template E
* @param iterable<K, V> $iterable
* @param ?callable(V, K, iterable<K, V>): bool $predicate
* @return ?K
* @param ?callable(): E $else
* @return ($else is null ? ?K : K|E)
*/
public static function firstKey(iterable $iterable, ?callable $predicate = null, ?callable $else = null): mixed
{
@@ -161,11 +167,11 @@ public static function map(iterable $iterable, callable $transformer): \Generato
* Iterator that transforms keys and values by calling $transformer. If it returns null, the element is skipped.
* @template K
* @template V
* @template ResV
* @template ResK
* @template ResV
* @param iterable<K, V> $iterable
* @param callable(V, K, iterable<K, V>): ?array{ResV, ResK} $transformer
* @return \Generator<ResV, ResK>
* @param callable(V, K, iterable<K, V>): ?array{ResK, ResV} $transformer
* @return \Generator<ResK, ResV>
*/
public static function mapWithKeys(iterable $iterable, callable $transformer): \Generator
{
@@ -188,9 +194,10 @@ public static function mapWithKeys(iterable $iterable, callable $transformer): \
*/
public static function repeatable(callable $factory): \IteratorAggregate
{
return new class ($factory) implements \IteratorAggregate {
return new class ($factory(...)) implements \IteratorAggregate {
public function __construct(
private $factory,
/** @var \Closure(): iterable<mixed, mixed> */
private \Closure $factory,
) {
}
@@ -215,7 +222,8 @@ public static function memoize(iterable $iterable): \IteratorAggregate
{
return new class (self::toIterator($iterable)) implements \IteratorAggregate {
public function __construct(
private \Iterator $iterator,
private readonly \Iterator $iterator,
/** @var array<array{mixed, mixed}> */
private array $cache = [],
) {
}