Skip to content

Commit 572d8d0

Browse files
committed
Add types to iterable_map()
1 parent 7da8363 commit 572d8d0

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
@@ -16,14 +16,19 @@
1616
/**
1717
* Maps a callable to an iterable.
1818
*
19-
* @param iterable<mixed> $iterable
19+
* @param iterable<TKey, TValue> $iterable
20+
* @param callable(TValue):TResult $mapper
21+
*
22+
* @return iterable<TKey, TValue2>
2023
*
21-
* @return iterable<mixed>
24+
* @template TKey
25+
* @template TValue
26+
* @template TResult
2227
*/
23-
function iterable_map(iterable $iterable, callable $map): iterable
28+
function iterable_map(iterable $iterable, callable $mapper): iterable
2429
{
2530
foreach ($iterable as $key => $item) {
26-
yield $key => $map($item);
31+
yield $key => $mapper($item);
2732
}
2833
}
2934

0 commit comments

Comments
 (0)