Skip to content

Commit

Permalink
psalm types
Browse files Browse the repository at this point in the history
  • Loading branch information
pfmmfp committed Sep 2, 2024
1 parent 4ddf2a6 commit 367b57a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
9 changes: 7 additions & 2 deletions src/Psl/Collection/MutableSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,18 @@ public static function fromArray(array $elements): MutableSet
*
* @template Ts of array-key
*
* @param iterable<Ts> $items
* @param iterable<Ts, Ts> $items
*
* @return MutableSet<Ts>
*/
public static function fromItems(iterable $items): MutableSet
{
return self::fromArray(iterator_to_array($items));
/**
* @psalm-suppress InvalidArgument
* @var array<Ts, Ts>
*/
$array = iterator_to_array($items);
return self::fromArray($array);
}

/**
Expand Down
9 changes: 7 additions & 2 deletions src/Psl/Collection/MutableVector.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,18 @@ public static function fromArray(array $elements): MutableVector
*
* @template Ts
*
* @param iterable<Ts> $items
* @param iterable<array-key, Ts> $items
*
* @return MutableVector<Ts>
*/
public static function fromItems(iterable $items): MutableVector
{
return self::fromArray(iterator_to_array($items));
/**
* @psalm-suppress InvalidArgument
* @var array<array-key, Ts>
*/
$array = iterator_to_array($items);
return self::fromArray($array);
}

/**
Expand Down
11 changes: 7 additions & 4 deletions src/Psl/Collection/Set.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,18 @@ public static function fromArray(array $elements): Set
*
* @template Ts of array-key
*
* @param iterable<Ts, mixed> $items
* @param iterable<array-key, Ts> $items
*
* @return Set<Ts>
*
* @pure
*/
public static function fromItems(iterable $items): Set
{
return self::fromArray(iterator_to_array($items));
/**
* @var array<array-key, Ts>
* @psalm-suppress InvalidArgument
*/
$array = iterator_to_array($items);
return self::fromArray($array);
}

/**
Expand Down
9 changes: 7 additions & 2 deletions src/Psl/Collection/Vector.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,18 @@ public static function fromArray(array $elements): Vector
*
* @template Ts
*
* @param iterable<Ts> $items
* @param iterable<array-key, Ts> $items
*
* @return Vector<Ts>
*/
public static function fromItems(iterable $items): Vector
{
return self::fromArray(iterator_to_array($items));
/**
* @psalm-suppress InvalidArgument
* @var array<array-key, Ts>
*/
$array = iterator_to_array($items);
return self::fromArray($array);
}

/**
Expand Down

0 comments on commit 367b57a

Please sign in to comment.