@@ -122,10 +122,11 @@ public static function contains(array $array, mixed $value): bool
122122
123123 /**
124124 * Returns the first item (matching the specified predicate if given). If there is no such item, it returns result of invoking $else or null.
125- * The $predicate has the signature `function (mixed $value, int|string $key, array $array): bool`.
126- * @template T
127- * @param array<T> $array
128- * @return ?T
125+ * @template K of int|string
126+ * @template V
127+ * @param array<K, V> $array
128+ * @param ?callable(V, K, array<K, V>): bool $predicate
129+ * @return ?V
129130 */
130131 public static function first (array $ array , ?callable $ predicate = null , ?callable $ else = null ): mixed
131132 {
@@ -138,10 +139,11 @@ public static function first(array $array, ?callable $predicate = null, ?callabl
138139
139140 /**
140141 * Returns the last item (matching the specified predicate if given). If there is no such item, it returns result of invoking $else or null.
141- * The $predicate has the signature `function (mixed $value, int|string $key, array $array): bool`.
142- * @template T
143- * @param array<T> $array
144- * @return ?T
142+ * @template K of int|string
143+ * @template V
144+ * @param array<K, V> $array
145+ * @param ?callable(V, K, array<K, V>): bool $predicate
146+ * @return ?V
145147 */
146148 public static function last (array $ array , ?callable $ predicate = null , ?callable $ else = null ): mixed
147149 {
@@ -154,7 +156,11 @@ public static function last(array $array, ?callable $predicate = null, ?callable
154156
155157 /**
156158 * Returns the key of first item (matching the specified predicate if given) or null if there is no such item.
157- * The $predicate has the signature `function (mixed $value, int|string $key, array $array): bool`.
159+ * @template K of int|string
160+ * @template V
161+ * @param array<K, V> $array
162+ * @param ?callable(V, K, array<K, V>): bool $predicate
163+ * @return ?K
158164 */
159165 public static function firstKey (array $ array , ?callable $ predicate = null ): int |string |null
160166 {
@@ -172,7 +178,11 @@ public static function firstKey(array $array, ?callable $predicate = null): int|
172178
173179 /**
174180 * Returns the key of last item (matching the specified predicate if given) or null if there is no such item.
175- * The $predicate has the signature `function (mixed $value, int|string $key, array $array): bool`.
181+ * @template K of int|string
182+ * @template V
183+ * @param array<K, V> $array
184+ * @param ?callable(V, K, array<K, V>): bool $predicate
185+ * @return ?K
176186 */
177187 public static function lastKey (array $ array , ?callable $ predicate = null ): int |string |null
178188 {
@@ -368,12 +378,11 @@ public static function pick(array &$array, string|int $key, mixed $default = nul
368378
369379
370380 /**
371- * Tests whether at least one element in the array passes the test implemented by the provided function,
372- * which has the signature `function ($value, $key, array $array): bool`.
373- * @template K
381+ * Tests whether at least one element in the array passes the test implemented by the provided function.
382+ * @template K of int|string
374383 * @template V
375- * @param iterable <K, V> $array
376- * @param callable(V, K, ($ array is array ? array <K, V> : iterable<K, V>)) : bool $predicate
384+ * @param array <K, V> $array
385+ * @param callable(V, K, array<K, V>) : bool $predicate
377386 */
378387 public static function some (iterable $ array , callable $ predicate ): bool
379388 {
@@ -388,12 +397,11 @@ public static function some(iterable $array, callable $predicate): bool
388397
389398
390399 /**
391- * Tests whether all elements in the array pass the test implemented by the provided function,
392- * which has the signature `function ($value, $key, array $array): bool`.
393- * @template K
400+ * Tests whether all elements in the array pass the test implemented by the provided function.
401+ * @template K of int|string
394402 * @template V
395- * @param iterable <K, V> $array
396- * @param callable(V, K, ($ array is array ? array <K, V> : iterable<K, V>)) : bool $predicate
403+ * @param array <K, V> $array
404+ * @param callable(V, K, array<K, V>) : bool $predicate
397405 */
398406 public static function every (iterable $ array , callable $ predicate ): bool
399407 {
@@ -409,11 +417,10 @@ public static function every(iterable $array, callable $predicate): bool
409417
410418 /**
411419 * Returns a new array containing all key-value pairs matching the given $predicate.
412- * The callback has the signature `function (mixed $value, int|string $key, array $array): bool`.
413- * @template K of array-key
420+ * @template K of int|string
414421 * @template V
415- * @param array<K, V> $array
416- * @param callable(V, K, array<K, V>): bool $predicate
422+ * @param array<K, V> $array
423+ * @param callable(V, K, array<K, V>): bool $predicate
417424 * @return array<K, V>
418425 */
419426 public static function filter (array $ array , callable $ predicate ): array
@@ -430,12 +437,11 @@ public static function filter(array $array, callable $predicate): array
430437
431438 /**
432439 * Returns an array containing the original keys and results of applying the given transform function to each element.
433- * The function has signature `function ($value, $key, array $array): mixed`.
434- * @template K of array-key
440+ * @template K of int|string
435441 * @template V
436442 * @template R
437- * @param iterable <K, V> $array
438- * @param callable(V, K, ($ array is array ? array <K, V> : iterable<K, V>)) : R $transformer
443+ * @param array <K, V> $array
444+ * @param callable(V, K, array<K, V>) : R $transformer
439445 * @return array<K, R>
440446 */
441447 public static function map (iterable $ array , callable $ transformer ): array
0 commit comments