Skip to content

Commit

Permalink
Improve phpstan docblock for Arrays::mapAssoc (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
frankdekker authored Sep 17, 2023
1 parent e23a525 commit aecdaf2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Arrays.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,13 @@ public static function findOrNull(array $items, callable $callback): mixed
* // output: [1 => false, 2 => true, 3 => false]
* </code>
* @template T
* @template V
* @template K of int|string
*
* @param T[] $items
* @param (callable(T): array{0: K, 1: T}) $callback
* @param (callable(T): array{0: K, 1: V}) $callback
*
* @return array<K, T>
* @return array<K, V>
*/
public static function mapAssoc(array $items, callable $callback): array
{
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/ArraysTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function testMapAssoc(): void

static::assertSame([], Arrays::mapAssoc([], $callback));
static::assertSame(['foo' => 'bar'], Arrays::mapAssoc([['foo', 'bar']], $callback));
static::assertSame([2 => false, 4 => true, 6 => false], Arrays::mapAssoc([1, 2, 3], static fn(int $val) => [$val * 2, $val % 2 === 0]));
}

public function testReindex(): void
Expand Down

0 comments on commit aecdaf2

Please sign in to comment.