Skip to content

Commit fb82343

Browse files
committed
Arrays::some(), every(), map() are annotated only for arrays
1 parent 0e3410d commit fb82343

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

src/Utils/Arrays.php

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,11 @@ public static function pick(array &$array, string|int $key, mixed $default = nul
369369

370370
/**
371371
* 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
372+
* which has the signature `function (mixed $value, int|string $key, array $array): bool`.
373+
* @template K of int|string
374374
* @template V
375-
* @param iterable<K, V> $array
376-
* @param callable(V, K, ($array is array ? array<K, V> : iterable<K, V>)): bool $predicate
375+
* @param array<K, V> $array
376+
* @param callable(V, K, array<K, V>): bool $predicate
377377
*/
378378
public static function some(iterable $array, callable $predicate): bool
379379
{
@@ -389,11 +389,10 @@ public static function some(iterable $array, callable $predicate): bool
389389

390390
/**
391391
* 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
392+
* @template K of int|string
394393
* @template V
395-
* @param iterable<K, V> $array
396-
* @param callable(V, K, ($array is array ? array<K, V> : iterable<K, V>)): bool $predicate
394+
* @param array<K, V> $array
395+
* @param callable(V, K, array<K, V>): bool $predicate
397396
*/
398397
public static function every(iterable $array, callable $predicate): bool
399398
{
@@ -409,11 +408,10 @@ public static function every(iterable $array, callable $predicate): bool
409408

410409
/**
411410
* 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
411+
* @template K of int|string
414412
* @template V
415413
* @param array<K, V> $array
416-
* @param callable(V, K, array<K, V>): bool $predicate
414+
* @param callable(V, K, array<K, V>): bool $predicate
417415
* @return array<K, V>
418416
*/
419417
public static function filter(array $array, callable $predicate): array
@@ -430,12 +428,11 @@ public static function filter(array $array, callable $predicate): array
430428

431429
/**
432430
* 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
431+
* @template K of int|string
435432
* @template V
436433
* @template R
437-
* @param iterable<K, V> $array
438-
* @param callable(V, K, ($array is array ? array<K, V> : iterable<K, V>)): R $transformer
434+
* @param array<K, V> $array
435+
* @param callable(V, K, array<K, V>): R $transformer
439436
* @return array<K, R>
440437
*/
441438
public static function map(iterable $array, callable $transformer): array

0 commit comments

Comments
 (0)