@@ -70,7 +70,7 @@ application as well.
7070
7171### each()
7272
73- ` method ` Cake\\ Collection\\ Collection::** each** ($callback)
73+ ` method ` Cake\\ Collection\\ Collection::** each** (callable $callback): CollectionInterface
7474
7575Collections can be iterated and/or transformed into new collections with the
7676` each() ` and ` map() ` methods. The ` each() ` method will not create a new
@@ -88,7 +88,7 @@ collection immediately applying the callback to each value in the collection.
8888
8989### map()
9090
91- ` method ` Cake\\ Collection\\ Collection::** map** ($callback): CollectionInterface
91+ ` method ` Cake\\ Collection\\ Collection::** map** (callable $callback): CollectionInterface
9292
9393The ` map() ` method will create a new collection based on the output of the
9494callback being applied to each object in the original collection:
@@ -113,7 +113,7 @@ the resulting items when iterated.
113113
114114### extract()
115115
116- ` method ` Cake\\ Collection\\ Collection::** extract** ($path): CollectionInterface
116+ ` method ` Cake\\ Collection\\ Collection::** extract** (callable|string $path): CollectionInterface
117117
118118One of the most common uses for a ` map() ` function is to extract a single
119119column from a collection. If you are looking to build a list of elements
@@ -188,7 +188,7 @@ Unlike `Cake\Utility\Hash::extract()` this method only supports the
188188
189189### combine()
190190
191- ` method ` Cake\\ Collection\\ Collection::** combine** ($keyPath, $valuePath, $groupPath = null): CollectionInterface
191+ ` method ` Cake\\ Collection\\ Collection::** combine** (callable|string $keyPath, callable|string $valuePath, callable|string|null $groupPath = null): CollectionInterface
192192
193193Collections allow you to create a new collection made from keys and values in
194194an existing collection. Both the key and value paths can be specified with
@@ -245,7 +245,7 @@ $combined = (new Collection($entities))->combine(
245245
246246### stopWhen()
247247
248- ` method ` Cake\\ Collection\\ Collection::** stopWhen** (callable $c ): CollectionInterface
248+ ` method ` Cake\\ Collection\\ Collection::** stopWhen** (callable|array $condition ): CollectionInterface
249249
250250You can stop the iteration at any point using the ` stopWhen() ` method. Calling
251251it in a collection will create a new one that will stop yielding results if the
@@ -266,7 +266,7 @@ $result = $new->toList();
266266
267267### unfold()
268268
269- ` method ` Cake\\ Collection\\ Collection::** unfold** (callable $callback): CollectionInterface
269+ ` method ` Cake\\ Collection\\ Collection::** unfold** (? callable $callback = null ): CollectionInterface
270270
271271Sometimes the internal items of a collection will contain arrays or iterators
272272with more items. If you wish to flatten the internal structure to iterate once
@@ -314,7 +314,7 @@ $result = $new->toList();
314314
315315### chunk()
316316
317- ` method ` Cake\\ Collection\\ Collection::** chunk** ($chunkSize): CollectionInterface
317+ ` method ` Cake\\ Collection\\ Collection::** chunk** (int $chunkSize): CollectionInterface
318318
319319When dealing with large amounts of items in a collection, it may make sense to
320320process the elements in batches instead of one by one. For splitting
@@ -345,7 +345,7 @@ $collection->map(function ($article) {
345345
346346### chunkWithKeys()
347347
348- ` method ` Cake\\ Collection\\ Collection::** chunkWithKeys** ($chunkSize): CollectionInterface
348+ ` method ` Cake\\ Collection\\ Collection::** chunkWithKeys** (int $chunkSize, bool $keepKeys = true ): CollectionInterface
349349
350350Much like ` chunk() ` , ` chunkWithKeys() ` allows you to slice up
351351a collection into smaller batches but with keys preserved. This is useful when
@@ -372,7 +372,7 @@ $result = $chunked->toList();
372372
373373### filter()
374374
375- ` method ` Cake\\ Collection\\ Collection::** filter** ($callback): CollectionInterface
375+ ` method ` Cake\\ Collection\\ Collection::** filter** (?callable $callback = null ): CollectionInterface
376376
377377Collections allow you to filter and create new collections based on
378378the result of callback functions. You can use ` filter() ` to create a new
@@ -390,7 +390,7 @@ $guys = $collection->filter(function ($person, $key) {
390390
391391### reject()
392392
393- ` method ` Cake\\ Collection\\ Collection::** reject** (callable $c ): CollectionInterface
393+ ` method ` Cake\\ Collection\\ Collection::** reject** (? callable $callback = null ): CollectionInterface
394394
395395The inverse of ` filter() ` is ` reject() ` . This method does a negative filter,
396396removing elements that match the filter function:
@@ -404,7 +404,7 @@ $ladies = $collection->reject(function ($person, $key) {
404404
405405### every()
406406
407- ` method ` Cake\\ Collection\\ Collection::** every** ($callback): bool
407+ ` method ` Cake\\ Collection\\ Collection::** every** (callable $callback): bool
408408
409409You can do truth tests with filter functions. To see if every element in
410410a collection matches a test you can use ` every() ` :
@@ -418,11 +418,11 @@ $allYoungPeople = $collection->every(function ($person) {
418418
419419### any()
420420
421- ` method ` Cake\\ Collection\\ Collection::** any** ($callback): bool
421+ ` method ` Cake\\ Collection\\ Collection::** any** (callable $callback): bool
422422
423423### some()
424424
425- ` method ` Cake\\ Collection\\ Collection::** some** ($callback): bool
425+ ` method ` Cake\\ Collection\\ Collection::** some** (callable $callback): bool
426426
427427You can see if the collection contains at least one element matching a filter
428428function using the ` any() ` method:
@@ -439,7 +439,7 @@ $hasYoungPeople = $collection->any(function ($person) {
439439
440440### match()
441441
442- ` method ` Cake\\ Collection\\ Collection::** match** ($conditions): CollectionInterface
442+ ` method ` Cake\\ Collection\\ Collection::** match** (array $conditions): CollectionInterface
443443
444444If you need to extract a new collection containing only the elements that
445445contain a given set of properties, you should use the ` match() ` method:
@@ -451,7 +451,7 @@ $commentsFromMark = $collection->match(['user.name' => 'Mark']);
451451
452452### firstMatch()
453453
454- ` method ` Cake\\ Collection\\ Collection::** firstMatch** ($conditions): mixed
454+ ` method ` Cake\\ Collection\\ Collection::** firstMatch** (array $conditions): mixed
455455
456456The property name can be a dot-separated path. You can traverse into nested
457457entities and match the values they contain. When you only need the first
@@ -474,7 +474,7 @@ against.
474474
475475### reduce()
476476
477- ` method ` Cake\\ Collection\\ Collection::** reduce** ($callback, $initial): mixed
477+ ` method ` Cake\\ Collection\\ Collection::** reduce** (callable $callback, mixed $initial = null ): mixed
478478
479479The counterpart of a ` map() ` operation is usually a ` reduce ` . This
480480function will help you build a single result out of all the elements in a
@@ -499,7 +499,7 @@ $allTags = $collection->reduce(function ($accumulated, $article) {
499499
500500### min()
501501
502- ` method ` Cake\\ Collection\\ Collection::** min** (string| callable $callback, $type = SORT_NUMERIC): mixed
502+ ` method ` Cake\\ Collection\\ Collection::** min** (callable|string $path, int $sort = SORT_NUMERIC): mixed
503503
504504To extract the minimum value for a collection based on a property, just use the
505505` min() ` function. This will return the full element from the collection and
@@ -526,7 +526,7 @@ $personWithYoungestDad = $collection->min('dad.age');
526526
527527### max()
528528
529- ` method ` Cake\\ Collection\\ Collection::** max** (string| callable $callback, $type = SORT_NUMERIC): mixed
529+ ` method ` Cake\\ Collection\\ Collection::** max** (callable|string $path, int $sort = SORT_NUMERIC): mixed
530530
531531The same can be applied to the ` max() ` function, which will return a single
532532element from the collection having the highest property value:
@@ -544,7 +544,7 @@ $personWithOldestDad = $collection->max('dad.age');
544544
545545### sumOf()
546546
547- ` method ` Cake\\ Collection\\ Collection::** sumOf** ($path = null): float|int
547+ ` method ` Cake\\ Collection\\ Collection::** sumOf** (callable|string|null $path = null): float|int
548548
549549Finally, the ` sumOf() ` method will return the sum of a property of all
550550elements:
@@ -562,7 +562,7 @@ $sumOfDadAges = $collection->sumOf('dad.age');
562562
563563### avg()
564564
565- ` method ` Cake\\ Collection\\ Collection::** avg** ($path = null): float|int|null
565+ ` method ` Cake\\ Collection\\ Collection::** avg** (callable|string|null $path = null): float|int|null
566566
567567Calculate the average value of the elements in the collection. Optionally
568568provide a matcher path, or function to extract values to generate the average
@@ -580,7 +580,7 @@ $average = (new Collection($items))->avg('invoice.total');
580580
581581### median()
582582
583- ` method ` Cake\\ Collection\\ Collection::** median** ($path = null): float|int|null
583+ ` method ` Cake\\ Collection\\ Collection::** median** (callable|string|null $path = null): float|int|null
584584
585585Calculate the median value of a set of elements. Optionally provide a matcher
586586path, or function to extract values to generate the median for:
@@ -602,7 +602,7 @@ $median = (new Collection($items))->median('invoice.total');
602602
603603### groupBy()
604604
605- ` method ` Cake\\ Collection\\ Collection::** groupBy** ($callback ): CollectionInterface
605+ ` method ` Cake\\ Collection\\ Collection::** groupBy** (callable|string $path ): CollectionInterface
606606
607607Collection values can be grouped by different keys in a new collection when they
608608share the same value for a property:
@@ -644,7 +644,7 @@ $classResults = $students->groupBy(function ($student) {
644644
645645### countBy()
646646
647- ` method ` Cake\\ Collection\\ Collection::** countBy** ($callback ): CollectionInterface
647+ ` method ` Cake\\ Collection\\ Collection::** countBy** (callable|string $path ): CollectionInterface
648648
649649If you only wish to know the number of occurrences per group, you can do so by
650650using the ` countBy() ` method. It takes the same arguments as ` groupBy ` so it
@@ -661,7 +661,7 @@ $classResults = $students->countBy(function ($student) {
661661
662662### indexBy()
663663
664- ` method ` Cake\\ Collection\\ Collection::** indexBy** ($callback ): CollectionInterface
664+ ` method ` Cake\\ Collection\\ Collection::** indexBy** (callable|string $path ): CollectionInterface
665665
666666There will be certain cases where you know an element is unique for the property
667667you want to group by. If you wish a single result per group, you can use the
@@ -691,7 +691,7 @@ $filesByHash = $files->indexBy(function ($file) {
691691
692692### zip()
693693
694- ` method ` Cake\\ Collection\\ Collection::** zip** ($items): CollectionInterface
694+ ` method ` Cake\\ Collection\\ Collection::** zip** (iterable ... $items): CollectionInterface
695695
696696The elements of different collections can be grouped together using the
697697` zip() ` method. It will return a new collection containing an array grouping
@@ -750,7 +750,7 @@ $result = $firstYear->zip($data[0], $data[1])->toList();
750750
751751### sortBy()
752752
753- ` method ` Cake\\ Collection\\ Collection::** sortBy** ($callback, $order = SORT_DESC, $sort = SORT_NUMERIC): CollectionInterface
753+ ` method ` Cake\\ Collection\\ Collection::** sortBy** (callable|string $path, int $order = SORT_DESC, int $sort = SORT_NUMERIC): CollectionInterface
754754
755755Collection values can be sorted in ascending or descending order based on
756756a column or custom function. To create a new sorted collection out of the values
@@ -818,7 +818,7 @@ $sorted = $collection->sortBy('title', SORT_ASC, SORT_NATURAL);
818818
819819### nest()
820820
821- ` method ` Cake\\ Collection\\ Collection::** nest** ($idPath, $parentPath, $nestingKey = 'children'): CollectionInterface
821+ ` method ` Cake\\ Collection\\ Collection::** nest** (callable|string $idPath, callable|string $parentPath, string $nestingKey = 'children'): CollectionInterface
822822
823823Not all data is meant to be represented in a linear way. Collections make it
824824easier to construct and flatten hierarchical or nested structures. Creating
@@ -870,7 +870,7 @@ rendering menus or traversing elements up to certain level in the tree.
870870
871871### listNested()
872872
873- ` method ` Cake\\ Collection\\ Collection::** listNested** ($order = 'desc', $nestingKey = 'children'): CollectionInterface
873+ ` method ` Cake\\ Collection\\ Collection::** listNested** (string|int $order = 'desc', callable|string $nestingKey = 'children'): CollectionInterface
874874
875875The inverse of ` nest() ` is ` listNested() ` . This method allows you to flatten
876876a tree structure back into a linear structure. It takes two parameters; the
@@ -961,7 +961,7 @@ $collection->isEmpty();
961961
962962### contains()
963963
964- ` method ` Cake\\ Collection\\ Collection::** contains** ($value): bool
964+ ` method ` Cake\\ Collection\\ Collection::** contains** (mixed $value): bool
965965
966966Collections allow you to quickly check if they contain one particular
967967value: by using the ` contains() ` method:
@@ -1020,7 +1020,7 @@ $result = $transpose->toList();
10201020
10211021### sample()
10221022
1023- ` method ` Cake\\ Collection\\ Collection::** sample** ($length = 10): CollectionInterface
1023+ ` method ` Cake\\ Collection\\ Collection::** sample** (int $length = 10): CollectionInterface
10241024
10251025Shuffling a collection is often useful when doing quick statistical analysis.
10261026Another common operation when doing this sort of task is withdrawing a few
@@ -1041,7 +1041,7 @@ sample, the full collection in a random order is returned.
10411041
10421042### take()
10431043
1044- ` method ` Cake\\ Collection\\ Collection::** take** ($length, $offset): CollectionInterface
1044+ ` method ` Cake\\ Collection\\ Collection::** take** (int $length = 1, int $offset = 0 ): CollectionInterface
10451045
10461046Whenever you want to take a slice of a collection use the ` take() ` function,
10471047it will create a new collection with at most the number of values you specify in
@@ -1058,7 +1058,7 @@ Positions are zero-based, therefore the first position number is `0`.
10581058
10591059### skip()
10601060
1061- ` method ` Cake\\ Collection\\ Collection::** skip** ($length): CollectionInterface
1061+ ` method ` Cake\\ Collection\\ Collection::** skip** (int $length): CollectionInterface
10621062
10631063While the second argument of ` take() ` can help you skip some elements before
10641064getting them from the collection, you can also use ` skip() ` for the same
@@ -1117,7 +1117,7 @@ $myTimeline->filter(function ($tweet) {
11171117
11181118### appendItem()
11191119
1120- ` method ` Cake\\ Collection\\ Collection::** appendItem** ($value, $key): CollectionInterface
1120+ ` method ` Cake\\ Collection\\ Collection::** appendItem** (mixed $item, mixed $key = null ): CollectionInterface
11211121
11221122Allows you to append an item with an optional key to the collection. If you
11231123specify a key that already exists in the collection, the value will not be
@@ -1130,7 +1130,7 @@ $myTimeline = $cakephpTweets->appendItem($newTweet, 99);
11301130
11311131### prepend()
11321132
1133- ` method ` Cake\\ Collection\\ Collection::** prepend** ($items): CollectionInterface
1133+ ` method ` Cake\\ Collection\\ Collection::** prepend** (iterable $items): CollectionInterface
11341134
11351135The ` prepend() ` method will return a new collection containing the values from
11361136both sources:
@@ -1142,7 +1142,7 @@ $myTimeline = $cakephpTweets->prepend($phpTweets);
11421142
11431143### prependItem()
11441144
1145- ` method ` Cake\\ Collection\\ Collection::** prependItem** ($value, $key): CollectionInterface
1145+ ` method ` Cake\\ Collection\\ Collection::** prependItem** (mixed $item, mixed $key = null ): CollectionInterface
11461146
11471147Allows you to prepend an item with an optional key to the collection. If you
11481148specify a key that already exists in the collection, the value will not be
@@ -1165,7 +1165,7 @@ $myTimeline = $cakephpTweets->prependItem($newTweet, 99);
11651165
11661166### insert()
11671167
1168- ` method ` Cake\\ Collection\\ Collection::** insert** ($path, $items ): CollectionInterface
1168+ ` method ` Cake\\ Collection\\ Collection::** insert** (string $path, mixed $values ): CollectionInterface
11691169
11701170At times, you may have two separate sets of data that you would like to insert
11711171the elements of one set into each of the elements of the other set. This is
@@ -1287,7 +1287,7 @@ $collection->map(new TotalOrderCalculator)
12871287
12881288### through()
12891289
1290- ` method ` Cake\\ Collection\\ Collection::** through** ($callback): CollectionInterface
1290+ ` method ` Cake\\ Collection\\ Collection::** through** (callable $callback): CollectionInterface
12911291
12921292Sometimes a chain of collection method calls can become reusable in other parts
12931293of your application, but only if they are called in that specific order. In
@@ -1410,7 +1410,7 @@ $rewindable = (new Collection(results()))->buffered();
14101410
14111411### compile()
14121412
1413- ` method ` Cake\\ Collection\\ Collection::** compile** ($preserveKeys = true): CollectionInterface
1413+ ` method ` Cake\\ Collection\\ Collection::** compile** (bool $keepKeys = true): CollectionInterface
14141414
14151415Sometimes you need to get a clone of the elements from another
14161416collection. This is useful when you need to iterate the same set from different
0 commit comments