Skip to content

Commit 09aeff9

Browse files
authored
Chore: Add types to iterable_map() (#28)
1 parent 5d99682 commit 09aeff9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/iterable-functions.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,18 @@
1515
/**
1616
* Maps a callable to an iterable.
1717
*
18-
* @param iterable<mixed> $iterable
18+
* @param iterable<TKey, TValue> $iterable
19+
* @param callable(TValue):TResult $mapper
1920
*
20-
* @return iterable<mixed>
21+
* @return iterable<TKey, TResult>
22+
*
23+
* @template TKey
24+
* @template TValue
25+
* @template TResult
2126
*/
22-
function iterable_map(iterable $iterable, callable $map): iterable
27+
function iterable_map(iterable $iterable, callable $mapper): iterable
2328
{
24-
$mapped = iterable($iterable)->map($map);
29+
$mapped = iterable($iterable)->map($mapper);
2530

2631
return is_array($iterable) ? $mapped->asArray() : $mapped;
2732
}

0 commit comments

Comments
 (0)