Skip to content

Commit b68bf85

Browse files
authored
Add object/interface return types to method signatures (#8174)
1 parent 526b1ef commit b68bf85

File tree

9 files changed

+24
-24
lines changed

9 files changed

+24
-24
lines changed

docs/en/controllers.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ view class.
204204

205205
### Rendering a View
206206

207-
`method` Cake\\Controller\\Controller::**render**(string $view, string $layout)
207+
`method` Cake\\Controller\\Controller::**render**(string $view, string $layout): Response
208208

209209
The `Controller::render()` method is automatically called at the end of each requested
210210
controller action. This method performs all the view logic (using the data
@@ -411,7 +411,7 @@ replaces usage of `RequestHandlerComponent` automatically using the
411411

412412
## Redirecting to Other Pages
413413

414-
`method` Cake\\Controller\\Controller::**redirect**(string|array $url, integer $status)
414+
`method` Cake\\Controller\\Controller::**redirect**(string|array $url, integer $status): Response|null
415415

416416
The `redirect()` method adds a `Location` header and sets the status code of
417417
a response and returns it. You should return the response created by
@@ -502,7 +502,7 @@ $authors = $this->fetchModel('Authors');
502502

503503
## Paginating a Model
504504

505-
`method` Cake\\Controller\\Controller::**paginate**()
505+
`method` Cake\\Controller\\Controller::**paginate**(): PaginatedInterface
506506

507507
This method is used for paginating results fetched by your models.
508508
You can specify page sizes, model find conditions and more. See the
@@ -525,7 +525,7 @@ class ArticlesController extends AppController
525525

526526
## Configuring Components to Load
527527

528-
`method` Cake\\Controller\\Controller::**loadComponent**($name, $config = [])
528+
`method` Cake\\Controller\\Controller::**loadComponent**($name, $config = []): Component
529529

530530
In your Controller's `initialize()` method you can define any components you
531531
want loaded, and any configuration data for them:

docs/en/controllers/request-response.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ necessary. In an CLI environment, where the concept of uploading files doesn't
218218
exist, it will allow to move the file that you've referenced irrespective of its
219219
origins, which makes testing file uploads possible.
220220

221-
`method` Cake\\Http\\ServerRequest::**getUploadedFile**($path)
221+
`method` Cake\\Http\\ServerRequest::**getUploadedFile**($path): UploadedFileInterface|null
222222

223223
Returns the uploaded file at a specific path. The path uses the same dot syntax as the
224224
`Cake\Http\ServerRequest::getData()` method:
@@ -281,7 +281,7 @@ $this->request = $this->request->withUploadedFiles($files);
281281
282282
### PUT, PATCH or DELETE Data
283283

284-
`method` Cake\\Http\\ServerRequest::**getBody**()
284+
`method` Cake\\Http\\ServerRequest::**getBody**(): StreamInterface
285285

286286
When building REST services, you often accept request data on `PUT` and
287287
`DELETE` requests. Any `application/x-www-form-urlencoded` request body data
@@ -1205,7 +1205,7 @@ The `CorsBuilder` provides the following methods for configuring CORS:
12051205

12061206
`method` Cake\\Http\\CorsBuilder::**maxAge**(string|int $age)
12071207

1208-
`method` Cake\\Http\\CorsBuilder::**build**()
1208+
`method` Cake\\Http\\CorsBuilder::**build**(): ResponseInterface
12091209

12101210
#### Practical CORS Examples
12111211

docs/en/core-libraries/caching.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ return $cloud;
419419

420420
### Cache::readMany()
421421

422-
`static` Cake\\Cache\\Cache::**readMany**($keys, $config = 'default')
422+
`static` Cake\\Cache\\Cache::**readMany**($keys, $config = 'default'): iterable
423423

424424
After you've written multiple keys at once, you'll probably want to read them as
425425
well. While you could use multiple calls to `read()`, `readMany()` allows

docs/en/core-libraries/hash.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ a matching path is not found the default value will be returned.
5858

5959
### Hash::extract()
6060

61-
`static` Cake\\Utility\\Hash::**extract**(array|ArrayAccess $data, $path)
61+
`static` Cake\\Utility\\Hash::**extract**(array|ArrayAccess $data, $path): ArrayAccess|array
6262

6363
`Hash::extract()` supports all expression, and matcher components of
6464
[Hash Path Syntax](#hash-path-syntax). You can use extract to retrieve data from arrays
@@ -130,7 +130,7 @@ $result = Hash::insert($data, '{n}[up].Item[id=4].new', 9);
130130

131131
### Hash::remove()
132132

133-
`static` Cake\\Utility\\Hash::**remove**(array $data, $path)
133+
`static` Cake\\Utility\\Hash::**remove**(array $data, $path): ArrayAccess|array
134134

135135
Removes all elements from an array that match `$path`:
136136

docs/en/core-libraries/xml.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ DOMDocument objects, and back into arrays again.
99

1010
### Xml::build()
1111

12-
`static` Cake\\Utility\\Xml::**build**($input, array $options = [])
12+
`static` Cake\\Utility\\Xml::**build**($input, array $options = []): SimpleXMLElement|DOMDocument
1313

1414
You can load XML-ish data using `Xml::build()`. Depending on your
1515
`$options` parameter, this method will return a SimpleXMLElement (default)

docs/en/orm/database-basics.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ references to existing connections.
339339

340340
### Accessing Connections
341341

342-
`static` Cake\\Datasource\\ConnectionManager::**get**($name)
342+
`static` Cake\\Datasource\\ConnectionManager::**get**($name): ConnectionInterface
343343

344344
Once configured connections can be fetched using
345345
`Cake\Datasource\ConnectionManager::get()`. This method will
@@ -956,7 +956,7 @@ transactional operations.
956956

957957
### Executing Queries
958958

959-
`method` Cake\\Database\\Connection::**execute(string $sql, array $params = [], array $types = []): \\Cake\\Database\\StatementInterface**()
959+
`method` Cake\\Database\\Connection::**execute**(string $sql, array $params = [], array $types = []): StatementInterface
960960

961961
Once you've gotten a connection object, you'll probably want to issue some
962962
queries with it. CakePHP's database abstraction layer provides wrapper features
@@ -990,7 +990,7 @@ $statement = $connection->execute(
990990
);
991991
```
992992

993-
`method` Cake\\Database\\Connection::**selectQuery**()
993+
`method` Cake\\Database\\Connection::**selectQuery**(): SelectQuery
994994

995995
These methods allow you to use rich data types in your applications and properly convert
996996
them into SQL statements. The last and most flexible way of creating queries is
@@ -1015,7 +1015,7 @@ foreach ($query as $row) {
10151015
> Instead of iterating the `$query` you can also call it's `all()` method
10161016
> to get the results.
10171017
1018-
`method` Cake\\Database\\Connection::**updateQuery**()
1018+
`method` Cake\\Database\\Connection::**updateQuery**(): UpdateQuery
10191019

10201020
This method provides you a builder for `UPDATE` queries:
10211021

@@ -1026,7 +1026,7 @@ $query = $connection->updateQuery('articles')
10261026
$statement = $query->execute();
10271027
```
10281028

1029-
`method` Cake\\Database\\Connection::**insertQuery**()
1029+
`method` Cake\\Database\\Connection::**insertQuery**(): InsertQuery
10301030

10311031
This method provides you a builder for `INSERT` queries:
10321032

@@ -1038,7 +1038,7 @@ $query->into('articles')
10381038
$statement = $query->execute();
10391039
```
10401040

1041-
`method` Cake\\Database\\Connection::**deleteQuery**()
1041+
`method` Cake\\Database\\Connection::**deleteQuery**(): DeleteQuery
10421042

10431043
This method provides you a builder for `DELETE` queries:
10441044

docs/en/orm/deleting-data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ $this->hasMany('Comments', [
6666
6767
## Bulk Deletes
6868

69-
`method` Cake\\ORM\\Table::**deleteMany**(iterable $entities, array $options = [])
69+
`method` Cake\\ORM\\Table::**deleteMany**(iterable $entities, array $options = []): iterable|false
7070

7171
If you have an array of entities you want to delete you can use `deleteMany()`
7272
to delete them in a single transaction:

docs/en/orm/retrieving-data-and-resultsets.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ways to inspect the data returned by the ORM.
2525

2626
## Getting a Single Entity by Primary Key
2727

28-
`method` Cake\\ORM\\Table::**get**(mixed $primaryKey, array|string $finder = 'all', CacheInterface|string|null $cache = null, Closure|string|null $cacheKey = null, mixed ...$args)
28+
`method` Cake\\ORM\\Table::**get**(mixed $primaryKey, array|string $finder = 'all', CacheInterface|string|null $cache = null, Closure|string|null $cacheKey = null, mixed ...$args): EntityInterface
2929

3030
It is often convenient to load a single entity from the database when editing or
3131
viewing entities and their related data. You can do this by using `get()`:
@@ -79,7 +79,7 @@ The parameters supported by `get()` are:
7979

8080
## Using Finders to Load Data
8181

82-
`method` Cake\\ORM\\Table::**find**(string $type = 'all', mixed ...$args)
82+
`method` Cake\\ORM\\Table::**find**(string $type = 'all', mixed ...$args): SelectQuery
8383

8484
Before you can work with entities, you'll need to load them. The easiest way to
8585
do this is using the `find()` method. The find method provides a short and

docs/en/orm/saving-data.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ The `strictFields` option was added in 5.3.0.
795795

796796
## Saving Entities
797797

798-
`method` Cake\\ORM\\Table::**save**(Entity $entity, array $options = [])
798+
`method` Cake\\ORM\\Table::**save**(Entity $entity, array $options = []): EntityInterface|false
799799

800800
When saving request data to your database you need to first hydrate a new entity
801801
using `newEntity()` for passing into `save()`. For example:
@@ -1253,7 +1253,7 @@ would not normally be able to.
12531253

12541254
## Strict Saving
12551255

1256-
`method` Cake\\ORM\\Table::**saveOrFail**(EntityInterface $entity, array $options = [])
1256+
`method` Cake\\ORM\\Table::**saveOrFail**(EntityInterface $entity, array $options = []): EntityInterface
12571257

12581258
Using this method will throw an
12591259
`Cake\ORM\Exception\PersistenceFailedException` if:
@@ -1285,7 +1285,7 @@ corresponding save events will be triggered.
12851285

12861286
## Find or Create an Entity
12871287

1288-
`method` Cake\\ORM\\Table::**findOrCreate**($search, $callback = null, $options = [])
1288+
`method` Cake\\ORM\\Table::**findOrCreate**($search, $callback = null, $options = []): EntityInterface
12891289

12901290
Find an existing record based on `$search` or create a new record using the
12911291
properties in `$search` and calling the optional `$callback`. This method is
@@ -1344,7 +1344,7 @@ $table->saveOrFail($record);
13441344

13451345
## Saving Multiple Entities
13461346

1347-
`method` Cake\\ORM\\Table::**saveMany**(iterable $entities, array $options = [])
1347+
`method` Cake\\ORM\\Table::**saveMany**(iterable $entities, array $options = []): iterable|false
13481348

13491349
Using this method you can save multiple entities atomically. `$entities` can
13501350
be an array of entities created using `newEntities()` / `patchEntities()`.

0 commit comments

Comments
 (0)