Skip to content

Commit 4c4082f

Browse files
authored
Add remaining return types to method signatures (#8175)
1 parent 2c8f49d commit 4c4082f

File tree

5 files changed

+40
-40
lines changed

5 files changed

+40
-40
lines changed

docs/en/core-libraries/collections.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -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)
91+
`method` Cake\\Collection\\Collection::**map**($callback): CollectionInterface
9292

9393
The `map()` method will create a new collection based on the output of the
9494
callback 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)
116+
`method` Cake\\Collection\\Collection::**extract**($path): CollectionInterface
117117

118118
One of the most common uses for a `map()` function is to extract a single
119119
column 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)
191+
`method` Cake\\Collection\\Collection::**combine**($keyPath, $valuePath, $groupPath = null): CollectionInterface
192192

193193
Collections allow you to create a new collection made from keys and values in
194194
an 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)
248+
`method` Cake\\Collection\\Collection::**stopWhen**(callable $c): CollectionInterface
249249

250250
You can stop the iteration at any point using the `stopWhen()` method. Calling
251251
it 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)
269+
`method` Cake\\Collection\\Collection::**unfold**(callable $callback): CollectionInterface
270270

271271
Sometimes the internal items of a collection will contain arrays or iterators
272272
with 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)
317+
`method` Cake\\Collection\\Collection::**chunk**($chunkSize): CollectionInterface
318318

319319
When dealing with large amounts of items in a collection, it may make sense to
320320
process 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)
348+
`method` Cake\\Collection\\Collection::**chunkWithKeys**($chunkSize): CollectionInterface
349349

350350
Much like `chunk()`, `chunkWithKeys()` allows you to slice up
351351
a 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)
375+
`method` Cake\\Collection\\Collection::**filter**($callback): CollectionInterface
376376

377377
Collections allow you to filter and create new collections based on
378378
the 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)
393+
`method` Cake\\Collection\\Collection::**reject**(callable $c): CollectionInterface
394394

395395
The inverse of `filter()` is `reject()`. This method does a negative filter,
396396
removing elements that match the filter function:
@@ -439,7 +439,7 @@ $hasYoungPeople = $collection->any(function ($person) {
439439
440440
### match()
441441

442-
`method` Cake\\Collection\\Collection::**match**($conditions)
442+
`method` Cake\\Collection\\Collection::**match**($conditions): CollectionInterface
443443

444444
If you need to extract a new collection containing only the elements that
445445
contain a given set of properties, you should use the `match()` method:
@@ -602,7 +602,7 @@ $median = (new Collection($items))->median('invoice.total');
602602

603603
### groupBy()
604604

605-
`method` Cake\\Collection\\Collection::**groupBy**($callback)
605+
`method` Cake\\Collection\\Collection::**groupBy**($callback): CollectionInterface
606606

607607
Collection values can be grouped by different keys in a new collection when they
608608
share 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)
647+
`method` Cake\\Collection\\Collection::**countBy**($callback): CollectionInterface
648648

649649
If you only wish to know the number of occurrences per group, you can do so by
650650
using 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)
664+
`method` Cake\\Collection\\Collection::**indexBy**($callback): CollectionInterface
665665

666666
There will be certain cases where you know an element is unique for the property
667667
you 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)
694+
`method` Cake\\Collection\\Collection::**zip**($items): CollectionInterface
695695

696696
The 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)
753+
`method` Cake\\Collection\\Collection::**sortBy**($callback, $order = SORT_DESC, $sort = SORT_NUMERIC): CollectionInterface
754754

755755
Collection values can be sorted in ascending or descending order based on
756756
a 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')
821+
`method` Cake\\Collection\\Collection::**nest**($idPath, $parentPath, $nestingKey = 'children'): CollectionInterface
822822

823823
Not all data is meant to be represented in a linear way. Collections make it
824824
easier 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')
873+
`method` Cake\\Collection\\Collection::**listNested**($order = 'desc', $nestingKey = 'children'): CollectionInterface
874874

875875
The inverse of `nest()` is `listNested()`. This method allows you to flatten
876876
a tree structure back into a linear structure. It takes two parameters; the
@@ -977,7 +977,7 @@ comparison types you can use the `some()` method.
977977

978978
### shuffle()
979979

980-
`method` Cake\\Collection\\Collection::**shuffle**()
980+
`method` Cake\\Collection\\Collection::**shuffle**(): CollectionInterface
981981

982982
Sometimes you may wish to show a collection of values in a random order. In
983983
order to create a new collection that will return each value in a randomized
@@ -992,7 +992,7 @@ $collection->shuffle()->toList();
992992

993993
### transpose()
994994

995-
`method` Cake\\Collection\\Collection::**transpose**()
995+
`method` Cake\\Collection\\Collection::**transpose**(): CollectionInterface
996996

997997
When you transpose a collection, you get a new collection containing a row made
998998
of the each of the original columns:
@@ -1020,7 +1020,7 @@ $result = $transpose->toList();
10201020

10211021
### sample()
10221022

1023-
`method` Cake\\Collection\\Collection::**sample**($length = 10)
1023+
`method` Cake\\Collection\\Collection::**sample**($length = 10): CollectionInterface
10241024

10251025
Shuffling a collection is often useful when doing quick statistical analysis.
10261026
Another 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)
1044+
`method` Cake\\Collection\\Collection::**take**($length, $offset): CollectionInterface
10451045

10461046
Whenever you want to take a slice of a collection use the `take()` function,
10471047
it 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)
1061+
`method` Cake\\Collection\\Collection::**skip**($length): CollectionInterface
10621062

10631063
While the second argument of `take()` can help you skip some elements before
10641064
getting them from the collection, you can also use `skip()` for the same
@@ -1098,7 +1098,7 @@ $collection->last(); // Returns 2
10981098

10991099
### append()
11001100

1101-
`method` Cake\\Collection\\Collection::**append**(array|Traversable $items)
1101+
`method` Cake\\Collection\\Collection::**append**(array|Traversable $items): CollectionInterface
11021102

11031103
You can compose multiple collections into a single one. This enables you to
11041104
gather data from various sources, concatenate it, and apply other collection
@@ -1117,7 +1117,7 @@ $myTimeline->filter(function ($tweet) {
11171117

11181118
### appendItem()
11191119

1120-
`method` Cake\\Collection\\Collection::**appendItem**($value, $key)
1120+
`method` Cake\\Collection\\Collection::**appendItem**($value, $key): CollectionInterface
11211121

11221122
Allows you to append an item with an optional key to the collection. If you
11231123
specify 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)
1133+
`method` Cake\\Collection\\Collection::**prepend**($items): CollectionInterface
11341134

11351135
The `prepend()` method will return a new collection containing the values from
11361136
both sources:
@@ -1142,7 +1142,7 @@ $myTimeline = $cakephpTweets->prepend($phpTweets);
11421142

11431143
### prependItem()
11441144

1145-
`method` Cake\\Collection\\Collection::**prependItem**($value, $key)
1145+
`method` Cake\\Collection\\Collection::**prependItem**($value, $key): CollectionInterface
11461146

11471147
Allows you to prepend an item with an optional key to the collection. If you
11481148
specify 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)
1168+
`method` Cake\\Collection\\Collection::**insert**($path, $items): CollectionInterface
11691169

11701170
At times, you may have two separate sets of data that you would like to insert
11711171
the 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)
1290+
`method` Cake\\Collection\\Collection::**through**($callback): CollectionInterface
12911291

12921292
Sometimes a chain of collection method calls can become reusable in other parts
12931293
of your application, but only if they are called in that specific order. In
@@ -1328,7 +1328,7 @@ $collection->through(new FinalCheckOutRowProcessor);
13281328

13291329
### buffered()
13301330

1331-
`method` Cake\\Collection\\Collection::**buffered**()
1331+
`method` Cake\\Collection\\Collection::**buffered**(): CollectionInterface
13321332

13331333
Collections often perform most operations that you create using its functions in
13341334
a lazy way. This means that even though you can call a function, it does not
@@ -1410,7 +1410,7 @@ $rewindable = (new Collection(results()))->buffered();
14101410

14111411
### compile()
14121412

1413-
`method` Cake\\Collection\\Collection::**compile**($preserveKeys = true)
1413+
`method` Cake\\Collection\\Collection::**compile**($preserveKeys = true): CollectionInterface
14141414

14151415
Sometimes you need to get a clone of the elements from another
14161416
collection. This is useful when you need to iterate the same set from different

docs/en/core-libraries/hash.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ $results = Hash::extract($users, '{n}.id');
7979
// [1,2,3,4];
8080
```
8181

82-
`static` Hash::**insert**(array $data, $path, $values = null)
82+
`static` Hash::**insert**(array $data, $path, $values = null): ArrayAccess|array
8383

8484
Inserts `$values` into an array as defined by `$path`:
8585

docs/en/core-libraries/logging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ appropriate log level.
539539
540540
### Log::log()
541541

542-
`method` Cake\\Log\\Log::**log**($msg, $level = LOG_ERR)
542+
`method` Cake\\Log\\Log::**log**($msg, $level = LOG_ERR): bool
543543

544544
## Using Monolog
545545

docs/en/development/debugging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ Although this method is used internally, it can be handy if you're
176176
creating your own error messages or log entries for custom
177177
situations.
178178

179-
`static` Debugger::**getType**($var)
179+
`static` Debugger::**getType**($var): string
180180

181181
Get the type of a variable. Objects will return their class name
182182

docs/en/development/sessions.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ In components, use `$this->getController()->getRequest()`.
392392

393393
## Reading & Writing Session Data
394394

395-
`method` Session::**read**($key, $default = null)
395+
`method` Session::**read**($key, $default = null): mixed
396396

397397
You can read values from the session using `Hash::extract()`
398398
compatible syntax:
@@ -401,7 +401,7 @@ compatible syntax:
401401
$session->read('Config.language', 'en');
402402
```
403403

404-
`method` Session::**readOrFail**($key)
404+
`method` Session::**readOrFail**($key): mixed
405405

406406
The same as convenience wrapper around non-nullable return value:
407407

@@ -412,7 +412,7 @@ $session->readOrFail('Config.language');
412412
This is useful, when you know this key has to be set and you don't want to have to check
413413
for the existence in code itself.
414414

415-
`method` Session::**write**($key, $value)
415+
`method` Session::**write**($key, $value): void
416416

417417
`$key` should be the dot separated path you wish to write `$value` to:
418418

@@ -429,7 +429,7 @@ $session->write([
429429
]);
430430
```
431431

432-
`method` Session::**delete**($key)
432+
`method` Session::**delete**($key): void
433433

434434
When you need to delete data from the session, you can use `delete()`:
435435

@@ -450,7 +450,7 @@ When you need to read and delete data from the session, you can use
450450
$session->consume('Some.value');
451451
```
452452

453-
`method` Session::**check**($key)
453+
`method` Session::**check**($key): bool
454454

455455
If you want to see if data exists in the session, you can use `check()`:
456456

@@ -462,7 +462,7 @@ if ($session->check('Config.language')) {
462462

463463
## Destroying the Session
464464

465-
`method` Session::**destroy**()
465+
`method` Session::**destroy**(): void
466466

467467
Destroying the session is useful when users log out. To destroy a session, use
468468
the `destroy()` method:
@@ -476,7 +476,7 @@ Destroying a session will remove all serverside data in the session, but will
476476

477477
## Rotating Session Identifiers
478478

479-
`method` Session::**renew**()
479+
`method` Session::**renew**(): void
480480

481481
While the `Authentication Plugin` automatically renews the session id when users login and
482482
logout, you may need to rotate the session id's manually. To do this use the

0 commit comments

Comments
 (0)