From 235b1c4dd021552cb84c208c188bb2b08402e70d Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Sat, 6 Feb 2021 16:40:11 +0100 Subject: [PATCH] Add types to iterable_to_array() --- src/iterable-functions.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/iterable-functions.php b/src/iterable-functions.php index df51b9d..9f1fa52 100644 --- a/src/iterable-functions.php +++ b/src/iterable-functions.php @@ -28,12 +28,17 @@ function iterable_map(iterable $iterable, callable $map): iterable } /** - * Copy the iterable into an array. If the iterable is already an array, return it. + * Copy the iterable into an array. * - * @param iterable $iterable + * @param iterable $iterable * @param bool $preserveKeys [optional] Whether to use the iterator element keys as index. * - * @return array + * @return array + * + * @psalm-return ($preserveKeys is true ? array : array) + * @psalm-template TKey as array-key + * @phpstan-template TKey + * @template TValue */ function iterable_to_array(iterable $iterable, bool $preserveKeys = true): array {