From 72328a11443a0de79967104ad36ba7b30bded134 Mon Sep 17 00:00:00 2001 From: Andreas Heigl Date: Tue, 3 Oct 2023 11:22:33 +0200 Subject: [PATCH] Improve return type for Collection::partition (#380) 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. --- src/Collection.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Collection.php b/src/Collection.php index e9fb58ed..5a763cea 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -100,4 +100,14 @@ public function map(Closure $func); * @psalm-return Collection */ public function filter(Closure $p); + + /** + * {@inheritDoc} + + * @return Collection[] 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, 1: Collection} + */ + public function partition(Closure $p); }