Skip to content

Commit 2a9f2d4

Browse files
authored
Fix remaining signature mismatches against CakePHP 5.x source. (#8216)
- RouteBuilder::prefix/plugin are instance methods, not static - CacheEngine::write/read renamed to set/get per PSR-16 - Session methods use $name parameter, not $key - ServerRequest::addDetector parameter is $detector - Response: fix nullable types, union types, and parameter names for withStringBody, withCache, withExpires, withEtag, withModified, withVary, withHeader - ConsoleIo::ask has 2 params (not 3), createFile has $forceOverwrite - LogTrait::log accepts Stringable|string and $context param - newClientResponse is on HttpClientTrait, not Response
1 parent ebb4688 commit 2a9f2d4

File tree

7 files changed

+21
-21
lines changed

7 files changed

+21
-21
lines changed

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

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

180180
## Getting User Input
181181

182-
`method` Cake\\Console\\ConsoleIo::**ask**(string $question, ?array $choices = null, ?string $default = null): string
182+
`method` Cake\\Console\\ConsoleIo::**ask**(string $prompt, ?string $default = null): string
183183

184184
When building interactive console applications you'll need to get user input.
185185
CakePHP provides a way to do this:
@@ -196,7 +196,7 @@ Selection validation is case-insensitive.
196196

197197
## Creating Files
198198

199-
`method` Cake\\Console\\ConsoleIo::**createFile**(string $path, string $contents): bool
199+
`method` Cake\\Console\\ConsoleIo::**createFile**(string $path, string $contents, bool $forceOverwrite = false): bool
200200

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

docs/en/controllers/request-response.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ detectors. There are different types of detectors that you can create:
395395
to handle the check. The callback will receive the request object as its only
396396
parameter.
397397

398-
`method` Cake\\Http\\ServerRequest::**addDetector**(string $name, Closure|array $options): void
398+
`method` Cake\\Http\\ServerRequest::**addDetector**(string $name, Closure|array $detector): void
399399

400400
Some examples would be:
401401

@@ -809,7 +809,7 @@ public function sendIcs()
809809

810810
### Setting Headers
811811

812-
`method` Cake\\Http\\Response::**withHeader**(string $header, string $value): static
812+
`method` Cake\\Http\\Response::**withHeader**(string $name, string|array $value): static
813813

814814
Setting headers is done with the `Cake\Http\Response::withHeader()`
815815
method. Like all the PSR-7 interface methods, this method returns a *new*
@@ -836,7 +836,7 @@ redirect location header.
836836

837837
### Setting the Body
838838

839-
`method` Cake\\Http\\Response::**withStringBody**(string $string): static
839+
`method` Cake\\Http\\Response::**withStringBody**(?string $string): static
840840

841841
To set a string as the response body, do the following:
842842

@@ -919,7 +919,7 @@ public function index()
919919
> Disabling caching from SSL domains while trying to send
920920
> files to Internet Explorer can result in errors.
921921
922-
`method` Cake\\Http\\Response::**withCache**(string $since, string $time = '+1 day'): static
922+
`method` Cake\\Http\\Response::**withCache**(string|int $since, string|int $time = '+1 day'): static
923923

924924
You can also tell clients that you want them to cache responses. By using
925925
`Cake\Http\Response::withCache()`:
@@ -998,7 +998,7 @@ the `Cache-Control` header.
998998

999999
#### The Expiration Header
10001000

1001-
`method` Cake\\Http\\Response::**withExpires**(DateTimeInterface|string $time): static
1001+
`method` Cake\\Http\\Response::**withExpires**(DateTimeInterface|string|int|null $time): static
10021002

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

10171017
#### The Etag Header
10181018

1019-
`method` Cake\\Http\\Response::**withEtag**(string $tag, bool $weak = false): static
1019+
`method` Cake\\Http\\Response::**withEtag**(string $hash, bool $weak = false): static
10201020

10211021
Cache validation in HTTP is often used when content is constantly changing, and
10221022
asks the application to only generate the response contents if the cache is no
@@ -1059,7 +1059,7 @@ public function index()
10591059
10601060
#### The Last Modified Header
10611061

1062-
`method` Cake\\Http\\Response::**withModified**(DateTimeInterface|string $time): static
1062+
`method` Cake\\Http\\Response::**withModified**(DateTimeInterface|string|int $time): static
10631063

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

10861086
#### The Vary Header
10871087

1088-
`method` Cake\\Http\\Response::**withVary**(string $header): static
1088+
`method` Cake\\Http\\Response::**withVary**(array|string $cacheVariances): static
10891089

10901090
In some cases, you might want to serve different content using the same URL.
10911091
This is often the case if you have a multilingual page or respond with different

docs/en/core-libraries/caching.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,9 +672,9 @@ The required API for a CacheEngine is
672672

673673
`class` Cake\\Cache\\**CacheEngine**
674674

675-
`method` Cake\\Cache\\CacheEngine::**write**(string $key, mixed $value, DateInterval|int|null $ttl = null): bool
675+
`method` Cake\\Cache\\CacheEngine::**set**(string $key, mixed $value, DateInterval|int|null $ttl = null): bool
676676

677-
`method` Cake\\Cache\\CacheEngine::**read**(string $key, mixed $default = null): mixed
677+
`method` Cake\\Cache\\CacheEngine::**get**(string $key, mixed $default = null): mixed
678678

679679
`method` Cake\\Cache\\CacheEngine::**delete**(string $key): bool
680680

docs/en/core-libraries/httpclient.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ $this->mockClientDelete(/* ... */);
596596

597597
### Response::newClientResponse()
598598

599-
`method` Cake\\Http\\TestSuite\\Response::**newClientResponse**(int $code = 200, array $headers = [], string $body = ''): Cake\\Http\\Client\\Response
599+
`method` Cake\\Http\\TestSuite\\HttpClientTrait::**newClientResponse**(int $code = 200, array $headers = [], string $body = ''): Cake\\Http\\Client\\Response
600600

601601
As seen above you can use the `newClientResponse()` method to create responses
602602
for the requests your application will make. The headers need to be a list of

docs/en/core-libraries/logging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ appropriate log level.
533533
534534
### Log::log()
535535

536-
`method` Cake\\Log\\Log::**log**(string $msg, string|int $level = LOG_ERR): bool
536+
`method` Cake\\Log\\LogTrait::**log**(Stringable|string $message, string|int $level = LogLevel::ERROR, array|string $context = []): bool
537537

538538
## Using Monolog
539539

docs/en/development/routing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ named. Nameless routes will not have the `_namePrefix` applied to them.
681681

682682
### Prefix Routing
683683

684-
`static` Cake\\Routing\\RouteBuilder::**prefix**(string $name, Closure|array $params = [], ?Closure $callback = null): static
684+
`method` Cake\\Routing\\RouteBuilder::**prefix**(string $name, Closure|array $params = [], ?Closure $callback = null): static
685685

686686
Many applications require an administration section where
687687
privileged users can make changes. This is often done through a
@@ -824,7 +824,7 @@ This would link to a controller with the namespace `App\Controller\Admin\MyPrefi
824824
825825
### Plugin Routing
826826

827-
`static` Cake\\Routing\\RouteBuilder::**plugin**(string $name, Closure|array $options = [], ?Closure $callback = null): static
827+
`method` Cake\\Routing\\RouteBuilder::**plugin**(string $name, Closure|array $options = [], ?Closure $callback = null): static
828828

829829
Routes for [Plugins](../plugins) should be created using the `plugin()`
830830
method. This method creates a new routing scope for the plugin's routes:

docs/en/development/sessions.md

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

391391
## Reading & Writing Session Data
392392

393-
`method` Session::**read**(?string $key = null, mixed $default = null): mixed
393+
`method` Session::**read**(?string $name = null, mixed $default = null): mixed
394394

395395
You can read values from the session using `Hash::extract()`
396396
compatible syntax:
@@ -399,7 +399,7 @@ compatible syntax:
399399
$session->read('Config.language', 'en');
400400
```
401401

402-
`method` Session::**readOrFail**(string $key): mixed
402+
`method` Session::**readOrFail**(string $name): mixed
403403

404404
The same as convenience wrapper around non-nullable return value:
405405

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

413-
`method` Session::**write**(array|string $key, mixed $value = null): void
413+
`method` Session::**write**(array|string $name, mixed $value = null): void
414414

415415
`$key` should be the dot separated path you wish to write `$value` to:
416416

@@ -427,7 +427,7 @@ $session->write([
427427
]);
428428
```
429429

430-
`method` Session::**delete**(string $key): void
430+
`method` Session::**delete**(string $name): void
431431

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

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

451-
`method` Session::**check**(?string $key = null): bool
451+
`method` Session::**check**(?string $name = null): bool
452452

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

0 commit comments

Comments
 (0)