Skip to content

Commit 2698e68

Browse files
committed
Add return types to method signatures
Add scalar/simple return types (string, int, float, bool, void, array, mixed, null, self, static, and union types) to 243 method signatures across 28 doc files, cross-referenced against the CakePHP 5.x source.
1 parent 5aba4ea commit 2698e68

28 files changed

Lines changed: 243 additions & 243 deletions

docs/en/console-commands/input-output.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ The `BannerHelper` was added in 5.1
181181

182182
## Getting User Input
183183

184-
`method` Cake\\Console\\ConsoleIo::**ask**($question, $choices = null, $default = null)
184+
`method` Cake\\Console\\ConsoleIo::**ask**($question, $choices = null, $default = null): string
185185

186186
When building interactive console applications you'll need to get user input.
187187
CakePHP provides a way to do this:
@@ -198,7 +198,7 @@ Selection validation is case-insensitive.
198198

199199
## Creating Files
200200

201-
`method` Cake\\Console\\ConsoleIo::**createFile**($path, $contents)
201+
`method` Cake\\Console\\ConsoleIo::**createFile**($path, $contents): bool
202202

203203
Creating files is often important part of many console commands that help
204204
automate development and deployment. The `createFile()` method gives you

docs/en/console-commands/option-parsers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ included its default value would be `false`, and when defined it will be
212212

213213
### Building a ConsoleOptionParser from an Array
214214

215-
`method` Cake\\Console\\ConsoleOptionParser::**buildFromArray**($spec)
215+
`method` Cake\\Console\\ConsoleOptionParser::**buildFromArray**($spec): static
216216

217217
Option parsers can also be defined as arrays. Within the array, you can define
218218
keys for `arguments`, `options`, `description` and `epilog`. The values

docs/en/controllers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ As of 4.1.0 you can also raise a `RedirectException` to signal a redirect.
612612

613613
## Controller Middleware
614614

615-
`method` Cake\\Controller\\Controller::**middleware**($middleware, array $options = [])
615+
`method` Cake\\Controller\\Controller::**middleware**($middleware, array $options = []): void
616616

617617
[Middleware](controllers/middleware) can be defined globally, in
618618
a routing scope or within a controller. To define middleware for a specific

docs/en/controllers/request-response.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ are also all found in the routing parameters:
8383

8484
### Query String Parameters
8585

86-
`method` Cake\\Http\\ServerRequest::**getQuery**($name, $default = null)
86+
`method` Cake\\Http\\ServerRequest::**getQuery**($name, $default = null): mixed
8787

8888
Query string parameters can be read using the `getQuery()` method:
8989

@@ -143,7 +143,7 @@ Casting functions were added.
143143

144144
### Request Body Data
145145

146-
`method` Cake\\Http\\ServerRequest::**getData**($name, $default = null)
146+
`method` Cake\\Http\\ServerRequest::**getData**($name, $default = null): mixed
147147

148148
All POST data normally available through PHP's `$_POST` global variable can be
149149
accessed using `Cake\Http\ServerRequest::getData()`. For example:
@@ -231,7 +231,7 @@ Unlike `Cake\Http\ServerRequest::getData()`, `Cake\Http\ServerRequest::getUpload
231231
only return data when an actual file upload exists for the given path, if there is regular, non-file request body data
232232
present at the given path, then this method will return `null`, just like it would for any non-existent path.
233233

234-
`method` Cake\\Http\\ServerRequest::**getUploadedFiles**()
234+
`method` Cake\\Http\\ServerRequest::**getUploadedFiles**(): array
235235

236236
Returns all uploaded files in a normalized array structure. For the above example with the file input name of
237237
`attachment`, the structure would look like:
@@ -244,7 +244,7 @@ Returns all uploaded files in a normalized array structure. For the above exampl
244244
]
245245
```
246246

247-
`method` Cake\\Http\\ServerRequest::**withUploadedFiles**(array $files)
247+
`method` Cake\\Http\\ServerRequest::**withUploadedFiles**(array $files): static
248248

249249
This method sets the uploaded files of the request object, it accepts an array of objects that implement
250250
[\Psr\Http\Message\UploadedFileInterface](https://www.php-fig.org/psr/psr-7/#16-uploaded-files). It will
@@ -304,7 +304,7 @@ types making the parsed data available in `$request->getData()` and
304304

305305
### Environment Variables (from \$\_SERVER and \$\_ENV)
306306

307-
`method` Cake\\Http\\ServerRequest::**getEnv**($key, $default = null)
307+
`method` Cake\\Http\\ServerRequest::**getEnv**($key, $default = null): string|null
308308

309309
`ServerRequest::getEnv()` is a wrapper for `getenv()` global function and acts as
310310
a getter for environment variables without possible undefined keys:
@@ -319,7 +319,7 @@ To access all the environment variables in a request use `getServerParams()`:
319319
$env = $this->request->getServerParams();
320320
```
321321

322-
`method` Cake\\Http\\ServerRequest::**withEnv**($key, $value)
322+
`method` Cake\\Http\\ServerRequest::**withEnv**($key, $value): static
323323

324324
`ServerRequest::withEnv()` is a wrapper for `putenv()` global function and acts as
325325
a setter for environment variables without having to modify globals
@@ -376,7 +376,7 @@ $base = $request->getAttribute('webroot');
376376

377377
### Checking Request Conditions
378378

379-
`method` Cake\\Http\\ServerRequest::**is**($type, $args...)
379+
`method` Cake\\Http\\ServerRequest::**is**($type, $args...): bool
380380

381381
The request object provides a way to inspect certain conditions in a given
382382
request. By using the `is()` method you can check a number of common
@@ -403,7 +403,7 @@ detectors. There are different types of detectors that you can create:
403403
to handle the check. The callback will receive the request object as its only
404404
parameter.
405405

406-
`method` Cake\\Http\\ServerRequest::**addDetector**($name, $options)
406+
`method` Cake\\Http\\ServerRequest::**addDetector**($name, $options): void
407407

408408
Some examples would be:
409409

@@ -500,7 +500,7 @@ to use the session object.
500500

501501
### Host and Domain Name
502502

503-
`method` Cake\\Http\\ServerRequest::**domain**($tldLength = 1)
503+
`method` Cake\\Http\\ServerRequest::**domain**($tldLength = 1): string
504504

505505
Returns the domain name your application is running on:
506506

@@ -509,7 +509,7 @@ Returns the domain name your application is running on:
509509
echo $request->domain();
510510
```
511511

512-
`method` Cake\\Http\\ServerRequest::**subdomains**($tldLength = 1)
512+
`method` Cake\\Http\\ServerRequest::**subdomains**($tldLength = 1): array
513513

514514
Returns the subdomains your application is running on as an array:
515515

@@ -518,7 +518,7 @@ Returns the subdomains your application is running on as an array:
518518
$subdomains = $request->subdomains();
519519
```
520520

521-
`method` Cake\\Http\\ServerRequest::**host**()
521+
`method` Cake\\Http\\ServerRequest::**host**(): string|null
522522

523523
Returns the host your application is on:
524524

@@ -529,7 +529,7 @@ echo $request->host();
529529

530530
### Reading the HTTP Method
531531

532-
`method` Cake\\Http\\ServerRequest::**getMethod**()
532+
`method` Cake\\Http\\ServerRequest::**getMethod**(): string
533533

534534
Returns the HTTP method the request was made with:
535535

@@ -540,7 +540,7 @@ echo $request->getMethod();
540540

541541
### Restricting Which HTTP method an Action Accepts
542542

543-
`method` Cake\\Http\\ServerRequest::**allowMethod**($methods)
543+
`method` Cake\\Http\\ServerRequest::**allowMethod**($methods): bool
544544

545545
Set allowed HTTP methods. If not matched, will throw
546546
`MethodNotAllowedException`. The 405 response will include the required
@@ -574,11 +574,11 @@ $hasAcceptHeader = $this->request->hasHeader('Accept');
574574
While some apache installs don't make the `Authorization` header accessible,
575575
CakePHP will make it available through apache specific methods as required.
576576

577-
`method` Cake\\Http\\ServerRequest::**referer**($local = true)
577+
`method` Cake\\Http\\ServerRequest::**referer**($local = true): string|null
578578

579579
Returns the referring address for the request.
580580

581-
`method` Cake\\Http\\ServerRequest::**clientIp**()
581+
`method` Cake\\Http\\ServerRequest::**clientIp**(): string
582582

583583
Returns the current visitor's IP address.
584584

@@ -616,7 +616,7 @@ proxy.
616616

617617
### Checking Accept Headers
618618

619-
`method` Cake\\Http\\ServerRequest::**accepts**($type = null)
619+
`method` Cake\\Http\\ServerRequest::**accepts**($type = null): array|bool
620620

621621
Find out which content types the client accepts, or check whether it accepts a
622622
particular type of content.
@@ -633,7 +633,7 @@ Check for a single type:
633633
$acceptsJson = $this->request->accepts('application/json');
634634
```
635635

636-
`method` Cake\\Http\\ServerRequest::**acceptLanguage**($language = null)
636+
`method` Cake\\Http\\ServerRequest::**acceptLanguage**($language = null): array|bool
637637

638638
Get all the languages accepted by the client,
639639
or check whether a specific language is accepted.
@@ -731,7 +731,7 @@ tasks such as:
731731

732732
### Dealing with Content Types
733733

734-
`method` Cake\\Http\\Response::**withType**($contentType = null)
734+
`method` Cake\\Http\\Response::**withType**($contentType = null): static
735735

736736
You can control the Content-Type of your application's responses with
737737
`Cake\Http\Response::withType()`. If your application needs to deal
@@ -754,7 +754,7 @@ automatic view switching provided by [Controller Viewclasses](../controllers#con
754754

755755
### Sending Files
756756

757-
`method` Cake\\Http\\Response::**withFile**(string $path, array $options = [])
757+
`method` Cake\\Http\\Response::**withFile**(string $path, array $options = []): static
758758

759759
There are times when you want to send files as responses for your requests.
760760
You can accomplish that by using `Cake\Http\Response::withFile()`:
@@ -850,7 +850,7 @@ redirect location header.
850850

851851
### Setting the Body
852852

853-
`method` Cake\\Http\\Response::**withStringBody**($string)
853+
`method` Cake\\Http\\Response::**withStringBody**($string): static
854854

855855
To set a string as the response body, do the following:
856856

@@ -905,7 +905,7 @@ $response = $response->withBody($stream);
905905

906906
### Setting the Character Set
907907

908-
`method` Cake\\Http\\Response::**withCharset**($charset)
908+
`method` Cake\\Http\\Response::**withCharset**($charset): static
909909

910910
Sets the charset that will be used in the response:
911911

@@ -915,7 +915,7 @@ $this->response = $this->response->withCharset('UTF-8');
915915

916916
### Interacting with Browser Caching
917917

918-
`method` Cake\\Http\\Response::**withDisabledCache**()
918+
`method` Cake\\Http\\Response::**withDisabledCache**(): static
919919

920920
You sometimes need to force browsers not to cache the results of a controller
921921
action. `Cake\Http\Response::withDisabledCache()` is intended for just
@@ -933,7 +933,7 @@ public function index()
933933
> Disabling caching from SSL domains while trying to send
934934
> files to Internet Explorer can result in errors.
935935
936-
`method` Cake\\Http\\Response::**withCache**($since, $time = '+1 day')
936+
`method` Cake\\Http\\Response::**withCache**($since, $time = '+1 day'): static
937937

938938
You can also tell clients that you want them to cache responses. By using
939939
`Cake\Http\Response::withCache()`:
@@ -971,7 +971,7 @@ or reverse proxy caching.
971971

972972
#### The Cache Control Header
973973

974-
`method` Cake\\Http\\Response::**withSharable**($public, $time = null)
974+
`method` Cake\\Http\\Response::**withSharable**($public, $time = null): static
975975

976976
Used under the expiration model, this header contains multiple indicators that
977977
can change the way browsers or proxies use the cached content. A
@@ -1012,7 +1012,7 @@ the `Cache-Control` header.
10121012

10131013
#### The Expiration Header
10141014

1015-
`method` Cake\\Http\\Response::**withExpires**($time)
1015+
`method` Cake\\Http\\Response::**withExpires**($time): static
10161016

10171017
You can set the `Expires` header to a date and time after which the response
10181018
is no longer considered fresh. This header can be set using the
@@ -1030,7 +1030,7 @@ be parsed by the `DateTime` class.
10301030

10311031
#### The Etag Header
10321032

1033-
`method` Cake\\Http\\Response::**withEtag**($tag, $weak = false)
1033+
`method` Cake\\Http\\Response::**withEtag**($tag, $weak = false): static
10341034

10351035
Cache validation in HTTP is often used when content is constantly changing, and
10361036
asks the application to only generate the response contents if the cache is no
@@ -1073,7 +1073,7 @@ public function index()
10731073
10741074
#### The Last Modified Header
10751075

1076-
`method` Cake\\Http\\Response::**withModified**($time)
1076+
`method` Cake\\Http\\Response::**withModified**($time): static
10771077

10781078
Also, under the HTTP cache validation model, you can set the `Last-Modified`
10791079
header to indicate the date and time at which the resource was modified for the
@@ -1099,7 +1099,7 @@ public function view()
10991099

11001100
#### The Vary Header
11011101

1102-
`method` Cake\\Http\\Response::**withVary**($header)
1102+
`method` Cake\\Http\\Response::**withVary**($header): static
11031103

11041104
In some cases, you might want to serve different content using the same URL.
11051105
This is often the case if you have a multilingual page or respond with different
@@ -1114,7 +1114,7 @@ $response = $this->response->withVary('Accept-Language');
11141114

11151115
#### Sending Not-Modified Responses
11161116

1117-
`method` Cake\\Http\\Response::**isNotModified**(Request $request)
1117+
`method` Cake\\Http\\Response::**isNotModified**(Request $request): bool
11181118

11191119
Compares the cache headers for the request object with the cache header from the
11201120
response and determines whether it can still be considered fresh. If so, deletes

docs/en/core-libraries/app.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The App class is responsible for resource location and path management.
88

99
### App::className()
1010

11-
`static` Cake\\Core\\App::**className**($name, $type = '', $suffix = '')
11+
`static` Cake\\Core\\App::**className**($name, $type = '', $suffix = ''): string|null
1212

1313
This method is used to resolve class names throughout CakePHP. It resolves
1414
the short form names CakePHP uses and returns the fully resolved class name:
@@ -35,7 +35,7 @@ class names do not exist, `false` will be returned.
3535

3636
### App::path()
3737

38-
`static` Cake\\Core\\App::**path**(string $package, ?string $plugin = null)
38+
`static` Cake\\Core\\App::**path**(string $package, ?string $plugin = null): array
3939

4040
The method returns paths set using `App.paths` app config:
4141

@@ -50,7 +50,7 @@ The same way you can retrieve paths for `locales` and `plugins`.
5050

5151
### App::classPath()
5252

53-
`static` Cake\\Core\\App::**classPath**(string $package, ?string $plugin = null)
53+
`static` Cake\\Core\\App::**classPath**(string $package, ?string $plugin = null): array
5454

5555
Used to get locations for paths based on conventions:
5656

@@ -67,7 +67,7 @@ for.
6767

6868
### App::core()
6969

70-
`static` Cake\\Core\\App::**core**(string $package)
70+
`static` Cake\\Core\\App::**core**(string $package): array
7171

7272
Used for finding the path to a package inside CakePHP:
7373

0 commit comments

Comments
 (0)