Skip to content

Commit 561b94f

Browse files
committed
Arrays::some(), every(), map() for iteratos & Mapper should be replaced by Iterators
1 parent 19db401 commit 561b94f

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

src/Iterators/Mapper.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
namespace Nette\Iterators;
1111

1212

13-
1413
/**
15-
* Applies the callback to the elements of the inner iterator.
14+
* @deprecated use Nette\Utils\Iterables::map()
1615
*/
1716
class Mapper extends \IteratorIterator
1817
{

src/Utils/Arrays.php

Lines changed: 12 additions & 12 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): bool`.
373-
* @template K
372+
* which has the signature `function (mixed $value, int|string $key, array $array): bool`.
373+
* @template K of array-key
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,11 @@ 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): bool`.
393-
* @template K
392+
* which has the signature `function (mixed $value, int|string $key, array $array): bool`.
393+
* @template K of array-key
394394
* @template V
395-
* @param iterable<K, V> $array
396-
* @param callable(V, K, ($array is array ? array<K, V> : iterable<K, V>)): bool $predicate
395+
* @param array<K, V> $array
396+
* @param callable(V, K, array<K, V>): bool $predicate
397397
*/
398398
public static function every(iterable $array, callable $predicate): bool
399399
{
@@ -409,7 +409,7 @@ public static function every(iterable $array, callable $predicate): bool
409409

410410
/**
411411
* Returns a new array containing all key-value pairs matching the given $predicate.
412-
* The callback has the signature `function ($value, $key, $array): bool`.
412+
* The callback has the signature `function (mixed $value, int|string $key, array $array): bool`.
413413
* @template K of array-key
414414
* @template V
415415
* @param array<K, V> $array
@@ -430,12 +430,12 @@ public static function filter(array $array, callable $predicate): array
430430

431431
/**
432432
* 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): mixed`.
433+
* The function has signature `function (mixed $value, int|string $key, array $array): mixed`.
434434
* @template K of array-key
435435
* @template V
436436
* @template R
437-
* @param iterable<K, V> $array
438-
* @param callable(V, K, ($array is array ? array<K, V> : iterable<K, V>)): R $transformer
437+
* @param array<K, V> $array
438+
* @param callable(V, K, array<K, V>): R $transformer
439439
* @return array<K, R>
440440
*/
441441
public static function map(iterable $array, callable $transformer): array

0 commit comments

Comments
 (0)