@@ -46,9 +46,10 @@ public function isNotEmpty(): bool;
4646 * Filter the collection based on a predicate.
4747 *
4848 * @param Closure(TValue):bool $predicate
49+ *
4950 * @return static
5051 */
51- public function filter (Closure $ predicate ): static ;
52+ public function filter ( Closure $ predicate ): static ;
5253
5354 /**
5455 * Filter out null values from the collection.
@@ -62,25 +63,28 @@ public function filterNotNull(): static;
6263 *
6364 * @template TOut
6465 * @param Closure(TValue):TOut $transform
66+ *
6567 * @return CollectionInterface<TKey, TOut>
6668 */
67- public function map (Closure $ transform ): CollectionInterface ;
69+ public function map ( Closure $ transform ): CollectionInterface ;
6870
6971 /**
7072 * Execute a function for each element in the collection.
7173 *
7274 * @param Closure(TValue):void $transform
75+ *
7376 * @return static
7477 */
75- public function foreach (Closure $ transform ): static ;
78+ public function foreach ( Closure $ transform ): static ;
7679
7780 /**
7881 * Determine if any element in the collection satisfies a predicate.
7982 *
8083 * @param Closure(TValue):bool $predicate
84+ *
8185 * @return bool
8286 */
83- public function any (Closure $ predicate ): bool ;
87+ public function any ( Closure $ predicate ): bool ;
8488
8589 /**
8690 * Retrieve the first element in the collection or null if empty.
@@ -93,25 +97,28 @@ public function firstOrNull(): mixed;
9397 * Determine if all elements in the collection satisfy a predicate.
9498 *
9599 * @param Closure(TValue):bool $predicate
100+ *
96101 * @return bool
97102 */
98- public function all (Closure $ predicate ): bool ;
103+ public function all ( Closure $ predicate ): bool ;
99104
100105 /**
101106 * Merge the collection with another array.
102107 *
103108 * @param array<TKey, TValue> $array
109+ *
104110 * @return static
105111 */
106- public function mergeArray (array $ array ): static ;
112+ public function mergeArray ( array $ array ): static ;
107113
108114 /**
109115 * Merge the collection with another collection.
110116 *
111117 * @param CollectionInterface<TKey, TValue> $collection
118+ *
112119 * @return static
113120 */
114- public function merge (CollectionInterface $ collection ): static ;
121+ public function merge ( CollectionInterface $ collection ): static ;
115122
116123 /**
117124 * Join elements of the collection into a string with a separator.
@@ -120,7 +127,7 @@ public function merge(CollectionInterface $collection): static;
120127 *
121128 * @return string
122129 */
123- public function join (string $ separator ): string ;
130+ public function join ( string $ separator ): string ;
124131
125132 /**
126133 * Apply a predicate if the collection is not empty.
@@ -131,7 +138,7 @@ public function join(string $separator): string;
131138 *
132139 * @return static
133140 */
134- public function maybe (Closure $ predicate ): static ;
141+ public function maybe ( Closure $ predicate ): static ;
135142
136143 /**
137144 * Convert the collection to a mutable variant.
@@ -157,4 +164,23 @@ public function toImmutable(): static;
157164 * @return static
158165 */
159166 public function flatten (): static ;
167+
168+ /**
169+ * Reduce the collection to a single value using a callback.
170+ *
171+ * @psalm-suppress PossiblyUnusedMethod
172+ *
173+ * @param Closure(mixed, TValue):mixed $transform
174+ * @param mixed|null $initial
175+ *
176+ * @return mixed
177+ */
178+ public function reduce ( Closure $ transform , mixed $ initial = null ): mixed ;
179+
180+ /**
181+ * Returns the current item and advances the internal pointer.
182+ *
183+ * @return TValue|null
184+ */
185+ public function nextAndGet (): mixed ;
160186}
0 commit comments