Skip to content

Commit 662e524

Browse files
committed
Arrays: improved phpDoc
1 parent 9631bcf commit 662e524

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/Utils/Arrays.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public static function flatten(array $array, bool $preserveKeys = false): array
217217
$res = [];
218218
$cb = $preserveKeys
219219
? function ($v, $k) use (&$res): void { $res[$k] = $v; }
220-
: function ($v) use (&$res): void { $res[] = $v; };
220+
: function ($v) use (&$res): void { $res[] = $v; };
221221
array_walk_recursive($array, $cb);
222222
return $res;
223223
}
@@ -330,17 +330,17 @@ public static function pick(array &$array, string|int $key, mixed $default = nul
330330

331331

332332
/**
333-
* Tests whether at least one element in the array passes the test implemented by the
334-
* provided callback with signature `function ($value, $key, array $array): bool`.
333+
* Tests whether at least one element in the array passes the test implemented by the provided function,
334+
* which has the signature `function ($value, $key, array $array): bool`.
335335
* @template K
336336
* @template V
337337
* @param iterable<K, V> $array
338-
* @param callable(V, K, ($array is array ? array<K, V> : iterable<K, V>)): bool $callback
338+
* @param callable(V, K, ($array is array ? array<K, V> : iterable<K, V>)): bool $predicate
339339
*/
340-
public static function some(iterable $array, callable $callback): bool
340+
public static function some(iterable $array, callable $predicate): bool
341341
{
342342
foreach ($array as $k => $v) {
343-
if ($callback($v, $k, $array)) {
343+
if ($predicate($v, $k, $array)) {
344344
return true;
345345
}
346346
}
@@ -355,12 +355,12 @@ public static function some(iterable $array, callable $callback): bool
355355
* @template K
356356
* @template V
357357
* @param iterable<K, V> $array
358-
* @param callable(V, K, ($array is array ? array<K, V> : iterable<K, V>)): bool $callback
358+
* @param callable(V, K, ($array is array ? array<K, V> : iterable<K, V>)): bool $predicate
359359
*/
360-
public static function every(iterable $array, callable $callback): bool
360+
public static function every(iterable $array, callable $predicate): bool
361361
{
362362
foreach ($array as $k => $v) {
363-
if (!$callback($v, $k, $array)) {
363+
if (!$predicate($v, $k, $array)) {
364364
return false;
365365
}
366366
}
@@ -370,20 +370,20 @@ public static function every(iterable $array, callable $callback): bool
370370

371371

372372
/**
373-
* Calls $callback on all elements in the array and returns the array of return values.
374-
* The callback has the signature `function ($value, $key, array $array): bool`.
373+
* Returns an array containing the original keys and results of applying the given transform function to each element.
374+
* The function has signature `function ($value, $key, array $array): mixed`.
375375
* @template K of array-key
376376
* @template V
377377
* @template R
378378
* @param iterable<K, V> $array
379-
* @param callable(V, K, ($array is array ? array<K, V> : iterable<K, V>)): R $callback
379+
* @param callable(V, K, ($array is array ? array<K, V> : iterable<K, V>)): R $transformer
380380
* @return array<K, R>
381381
*/
382-
public static function map(iterable $array, callable $callback): array
382+
public static function map(iterable $array, callable $transformer): array
383383
{
384384
$res = [];
385385
foreach ($array as $k => $v) {
386-
$res[$k] = $callback($v, $k, $array);
386+
$res[$k] = $transformer($v, $k, $array);
387387
}
388388

389389
return $res;

0 commit comments

Comments
 (0)