Skip to content

Commit

Permalink
Improve return type for Collection::partition (#380)
Browse files Browse the repository at this point in the history
Currently when partitioning a Collection-object it will return an array
of ReadableCollections unless that return-type is overwritten in the
implementation.

This change makes sure that any implementation of a Collection actually
returns an array of Collections instead.
  • Loading branch information
heiglandreas authored Oct 3, 2023
1 parent e695349 commit 72328a1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,14 @@ public function map(Closure $func);
* @psalm-return Collection<TKey, T>
*/
public function filter(Closure $p);

/**
* {@inheritDoc}
* @return Collection<mixed>[] An array with two elements. The first element contains the collection
* of elements where the predicate returned TRUE, the second element
* contains the collection of elements where the predicate returned FALSE.
* @psalm-return array{0: Collection<TKey, T>, 1: Collection<TKey, T>}
*/
public function partition(Closure $p);
}

0 comments on commit 72328a1

Please sign in to comment.