Skip to content

Commit d520351

Browse files
authored
Add type annotations to method signatures (#8182)
Updates signatures to include full type annotations matching CakePHP 5.x source: - Cache: setConfig, drop, write, writeMany, remember, read, readMany, delete, deleteMany, clear, increment, decrement, clearGroup, groupConfigs - Controller: loadComponent, middleware - PaginatorHelper: setPaginated, setTemplates, sort, numbers, prev, next, first, last, hasNext, limitControl, options
1 parent acef6f9 commit d520351

3 files changed

Lines changed: 27 additions & 27 deletions

File tree

docs/en/controllers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ class ArticlesController extends AppController
525525

526526
## Configuring Components to Load
527527

528-
`method` Cake\\Controller\\Controller::**loadComponent**($name, $config = []): Component
528+
`method` Cake\\Controller\\Controller::**loadComponent**(string $name, array $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:
@@ -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 = []): void
615+
`method` Cake\\Controller\\Controller::**middleware**(MiddlewareInterface|Closure|string $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/core-libraries/caching.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Regardless of the CacheEngine you choose to use, your application interacts with
4141

4242
### Cache::setConfig()
4343

44-
`static` Cake\\Cache\\Cache::**setConfig**($key, $config = null): void
44+
`static` Cake\\Cache\\Cache::**setConfig**(array|string $key, $config = null): void
4545

4646
Your application can configure any number of 'engines' during its bootstrap
4747
process. Cache engine configurations are defined in **config/app.php**.
@@ -269,7 +269,7 @@ When there is no fallback cache failures will be raised as exceptions.
269269

270270
### Cache::drop()
271271

272-
`static` Cake\\Cache\\Cache::**drop**($key): bool
272+
`static` Cake\\Cache\\Cache::**drop**(string $key): bool
273273

274274
Once a configuration is created you cannot change it. Instead you should drop
275275
the configuration and re-create it using `Cake\Cache\Cache::drop()` and
@@ -280,7 +280,7 @@ the config and destroy the adapter if it was constructed.
280280

281281
### Cache::write()
282282

283-
`static` Cake\\Cache\\Cache::**write**($key, $value, $config = 'default'): bool
283+
`static` Cake\\Cache\\Cache::**write**(string $key, mixed $value, string $config = 'default'): bool
284284

285285
`Cache::write()` will write a \$value to the Cache. You can read or
286286
delete this value later by referring to it by `$key`. You may
@@ -307,7 +307,7 @@ of trips made to the database to fetch posts.
307307
308308
### Cache::writeMany()
309309

310-
`static` Cake\\Cache\\Cache::**writeMany**($data, $config = 'default'): bool
310+
`static` Cake\\Cache\\Cache::**writeMany**(iterable $data, string $config = 'default'): bool
311311

312312
You may find yourself needing to write multiple cache keys at once. While you
313313
can use multiple calls to `write()`, `writeMany()` allows CakePHP to use
@@ -349,7 +349,7 @@ Cache::delete($lockKey);
349349
350350
### Cache::remember()
351351

352-
`static` Cake\\Cache\\Cache::**remember**($key, $callable, $config = 'default'): mixed
352+
`static` Cake\\Cache\\Cache::**remember**(string $key, Closure $callable, string $config = 'default'): mixed
353353

354354
Cache helps with read-through caching. If the named cache key exists,
355355
it will be returned. If the key does not exist, the callable will be invoked
@@ -374,7 +374,7 @@ class IssueService
374374

375375
### Cache::read()
376376

377-
`static` Cake\\Cache\\Cache::**read**($key, $config = 'default'): mixed
377+
`static` Cake\\Cache\\Cache::**read**(string $key, string $config = 'default'): mixed
378378

379379
`Cache::read()` is used to read the cached value stored under
380380
`$key` from the `$config`. If `$config` is null the default
@@ -419,7 +419,7 @@ return $cloud;
419419

420420
### Cache::readMany()
421421

422-
`static` Cake\\Cache\\Cache::**readMany**($keys, $config = 'default'): iterable
422+
`static` Cake\\Cache\\Cache::**readMany**(iterable $keys, string $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
@@ -439,7 +439,7 @@ $result = Cache::readMany([
439439

440440
### Cache::delete()
441441

442-
`static` Cake\\Cache\\Cache::**delete**($key, $config = 'default'): bool
442+
`static` Cake\\Cache\\Cache::**delete**(string $key, string $config = 'default'): bool
443443

444444
`Cache::delete()` will allow you to completely remove a cached
445445
object from the store:
@@ -458,7 +458,7 @@ Cache::pool('redis')->deleteAsync('my_key');
458458

459459
### Cache::deleteMany()
460460

461-
`static` Cake\\Cache\\Cache::**deleteMany**($keys, $config = 'default'): bool
461+
`static` Cake\\Cache\\Cache::**deleteMany**(iterable $keys, string $config = 'default'): bool
462462

463463
After you've written multiple keys at once, you may want to delete them. While
464464
you could use multiple calls to `delete()`, `deleteMany()` allows CakePHP to use
@@ -478,7 +478,7 @@ $result = Cache::deleteMany([
478478

479479
### Cache::clear()
480480

481-
`static` Cake\\Cache\\Cache::**clear**($config = 'default'): bool
481+
`static` Cake\\Cache\\Cache::**clear**(string $config = 'default'): bool
482482

483483
Destroy all cached values for a cache configuration. In engines like: Apcu,
484484
Memcached, the cache configuration's prefix is used to remove
@@ -505,11 +505,11 @@ Cache::pool('redis')->clearBlocking();
505505

506506
### Cache::increment()
507507

508-
`static` Cake\\Cache\\Cache::**increment**($key, $offset = 1, $config = 'default'): int|false
508+
`static` Cake\\Cache\\Cache::**increment**(string $key, int $offset = 1, string $config = 'default'): int|false
509509

510510
### Cache::decrement()
511511

512-
`static` Cake\\Cache\\Cache::**decrement**($key, $offset = 1, $config = 'default'): int|false
512+
`static` Cake\\Cache\\Cache::**decrement**(string $key, int $offset = 1, string $config = 'default'): int|false
513513

514514
Counters in your application are good candidates for storage in a cache. As an
515515
example, a simple countdown for remaining 'slots' in a contest could be stored
@@ -563,7 +563,7 @@ Cache::setConfig('site_home', [
563563

564564
### Cache::clearGroup()
565565

566-
`method` Cake\\Cache\\Cache::**clearGroup**($group, $config = 'default'): bool
566+
`static` Cake\\Cache\\Cache::**clearGroup**(string $group, string $config = 'default'): bool
567567

568568
Let's say you want to store the HTML generated for your homepage in cache, but
569569
would also want to automatically invalidate this cache every time a comment or
@@ -586,7 +586,7 @@ public function afterSave($event, $entity, $options = [])
586586

587587
### Cache::groupConfigs()
588588

589-
`static` Cake\\Cache\\Cache::**groupConfigs**($group = null): array
589+
`static` Cake\\Cache\\Cache::**groupConfigs**(?string $group = null): array
590590

591591
`groupConfigs()` can be used to retrieve mapping between group and
592592
configurations, i.e.: having the same group:

docs/en/views/helpers/paginator.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ create paginated datasets and do paginated queries.
1010

1111
## Setting the paginated resultset
1212

13-
`method` Cake\\View\\Helper\\PaginatorHelper::**setPaginated**($paginated, $options): void
13+
`method` Cake\\View\\Helper\\PaginatorHelper::**setPaginated**(PaginatedInterface $paginated, array $options = []): void
1414

1515
By default the helper uses the first instance of `Cake\Datasource\Paging\PaginatedInterface`
1616
it finds in the view variables. (Generally the result of `Controller::paginate()`).
@@ -68,7 +68,7 @@ return [
6868

6969
## Changing Templates at Run-time
7070

71-
`method` Cake\\View\\Helper\\PaginatorHelper::**setTemplates**($templates)
71+
`method` Cake\\View\\Helper\\PaginatorHelper::**setTemplates**(array $templates): $this
7272

7373
This method allows you to change the templates used by PaginatorHelper at
7474
runtime. This can be useful when you want to customize templates for a
@@ -112,7 +112,7 @@ PaginatorHelper uses the following templates:
112112

113113
### Creating Sort Links
114114

115-
`method` Cake\\View\\Helper\\PaginatorHelper::**sort**($key, $title = null, $options = []): string
115+
`method` Cake\\View\\Helper\\PaginatorHelper::**sort**(string $key, array|string|null $title = null, array $options = []): string
116116

117117
Generates a sorting link. Sets querystring parameters for the sort and
118118
direction. Links will default to sorting by asc. After the first click, links
@@ -195,7 +195,7 @@ echo $this->Paginator->sort('user_id', null, ['direction' => 'asc', 'lock' => tr
195195

196196
### Creating Page Number Links
197197

198-
`method` Cake\\View\\Helper\\PaginatorHelper::**numbers**($options = []): string
198+
`method` Cake\\View\\Helper\\PaginatorHelper::**numbers**(array $options = []): string
199199

200200
Returns a set of numbers for the paged result set. Uses a modulus to
201201
decide how many numbers to show on each side of the current page By default
@@ -251,19 +251,19 @@ pages in the paged data set.
251251

252252
### prev()
253253

254-
`method` Cake\\View\\Helper\\PaginatorHelper::**prev**($title = '<< Previous', $options = []): string
254+
`method` Cake\\View\\Helper\\PaginatorHelper::**prev**(string $title = '<< Previous', array $options = []): string
255255

256256
### next()
257257

258-
`method` Cake\\View\\Helper\\PaginatorHelper::**next**($title = 'Next >>', $options = []): string
258+
`method` Cake\\View\\Helper\\PaginatorHelper::**next**(string $title = 'Next >>', array $options = []): string
259259

260260
### first()
261261

262-
`method` Cake\\View\\Helper\\PaginatorHelper::**first**($first = '<< first', $options = []): string
262+
`method` Cake\\View\\Helper\\PaginatorHelper::**first**(string|int $first = '<< first', array $options = []): string
263263

264264
### last()
265265

266-
`method` Cake\\View\\Helper\\PaginatorHelper::**last**($last = 'last >>', $options = []): string
266+
`method` Cake\\View\\Helper\\PaginatorHelper::**last**(string|int $last = 'last >>', array $options = []): string
267267

268268
### Creating Header Link Tags
269269

@@ -286,7 +286,7 @@ echo $this->Paginator->meta(['first' => true, 'last' => true]);
286286

287287
#### hasNext()
288288

289-
`method` Cake\\View\\Helper\\PaginatorHelper::**hasNext**(string $model = null): bool
289+
`method` Cake\\View\\Helper\\PaginatorHelper::**hasNext**(): bool
290290

291291
#### hasPrev()
292292

@@ -362,7 +362,7 @@ echo $this->Paginator->generateUrl(
362362

363363
### Creating a Limit Selectbox Control
364364

365-
`method` Cake\\View\\Helper\\PaginatorHelper::**limitControl**(array $limits = [], $default = null, array $options = []): string
365+
`method` Cake\\View\\Helper\\PaginatorHelper::**limitControl**(array $limits = [], ?int $default = null, array $options = []): string
366366

367367
Create a dropdown control that changes the `limit` query parameter:
368368

@@ -419,7 +419,7 @@ automatically use the `maxLimit` value as the only available option.
419419

420420
### Configuring Pagination Options
421421

422-
`method` Cake\\View\\Helper\\PaginatorHelper::**options**($options = []): void
422+
`method` Cake\\View\\Helper\\PaginatorHelper::**options**(array $options = []): void
423423

424424
Sets all the options for the PaginatorHelper. Supported options are:
425425

0 commit comments

Comments
 (0)