Skip to content

Commit 0e83463

Browse files
authored
Fix remaining method signature issues across documentation (#8185)
* Add missing type annotations to core library method signatures Updated method signatures to include proper type annotations: - app.md: className() parameter types - collections.md: ~33 methods with full type annotations - email.md: setAttachments(), setEmailPattern() types and return - inflector.md: All 10 methods already had types (verified) - number.md: setDefaultCurrency() static and nullable type - text.md: transliterate(), toList() types (verified) - time.md: setJsonEncodeFormat(), i18nFormat(), comparison methods - xml.md: build(), toArray() types (verified) Refs #7744 * Fix remaining method signature issues across documentation - Fix malformed markdown syntax in table-objects.md (buildRules) and counter-cache.md (updateCounterCache) causing rendering issues - Add missing type annotations to ORM methods (save, findOrCreate, updateAll, deleteAll, Entity methods, ConnectionManager, TypeFactory) - Add parameter types to Controller methods (set, addViewClasses, fetchTable, fetchModel) - Add types to Response and CorsBuilder methods in request-response.md - Add types to ConsoleOptionParser methods in option-parsers.md - Add types to Helper callback methods and PaginatorHelper methods
1 parent 9804ff3 commit 0e83463

File tree

11 files changed

+42
-42
lines changed

11 files changed

+42
-42
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function getOptionParser()
3838

3939
## Using Arguments
4040

41-
`method` Cake\\Console\\ConsoleOptionParser::**addArgument**($name, $params = [])
41+
`method` Cake\\Console\\ConsoleOptionParser::**addArgument**(string $name, array $params = []): static
4242

4343
Positional arguments are frequently used in command line tools,
4444
and `ConsoleOptionParser` allows you to define positional
@@ -73,7 +73,7 @@ The `separator` option was added.
7373

7474
### Adding Multiple Arguments
7575

76-
`method` Cake\\Console\\ConsoleOptionParser::**addArguments**(array $args)
76+
`method` Cake\\Console\\ConsoleOptionParser::**addArguments**(array $args): static
7777

7878
If you have an array with multiple arguments you can use
7979
`$parser->addArguments()` to add multiple arguments at once. :
@@ -109,7 +109,7 @@ will be raised and the shell will be stopped.
109109

110110
## Using Options
111111

112-
`method` Cake\\Console\\ConsoleOptionParser::**addOption**($name, array $options = [])
112+
`method` Cake\\Console\\ConsoleOptionParser::**addOption**(string $name, array $options = []): static
113113

114114
Options or flags are used in command line tools to provide unordered key/value
115115
arguments for your commands. Options can define both verbose and short aliases.
@@ -164,7 +164,7 @@ The `separator` option was added.
164164

165165
### Adding Multiple Options
166166

167-
`method` Cake\\Console\\ConsoleOptionParser::**addOptions**(array $options)
167+
`method` Cake\\Console\\ConsoleOptionParser::**addOptions**(array $options): static
168168

169169
If you have an array with multiple options you can use `$parser->addOptions()`
170170
to add multiple options at once. :
@@ -241,7 +241,7 @@ public function getOptionParser()
241241

242242
### Merging Option Parsers
243243

244-
`method` Cake\\Console\\ConsoleOptionParser::**merge**($spec)
244+
`method` Cake\\Console\\ConsoleOptionParser::**merge**(ConsoleOptionParser $spec): static
245245

246246
When building a group command, you maybe want to combine several parsers for
247247
this:
@@ -348,7 +348,7 @@ epilog.
348348

349349
### Set the Description
350350

351-
`method` Cake\\Console\\ConsoleOptionParser::**setDescription**($text)
351+
`method` Cake\\Console\\ConsoleOptionParser::**setDescription**(array|string $text): static
352352

353353
The description displays above the argument and option information. By passing
354354
in either an array or a string, you can set the value of the description:
@@ -363,7 +363,7 @@ $parser->getDescription();
363363

364364
### Set the Epilog
365365

366-
`method` Cake\\Console\\ConsoleOptionParser::**setEpilog**($text)
366+
`method` Cake\\Console\\ConsoleOptionParser::**setEpilog**(array|string $text): static
367367

368368
Gets or sets the epilog for the option parser. The epilog is displayed after the
369369
argument and option information. By passing in either an array or a string, you

docs/en/controllers.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ rendered from the controller.
147147

148148
### Setting View Variables
149149

150-
`method` Cake\\Controller\\Controller::**set**(string $var, mixed $value)
150+
`method` Cake\\Controller\\Controller::**set**(string $var, mixed $value): void
151151

152152
The `Controller::set()` method is the main way to send data from your
153153
controller to your view. Once you've used `Controller::set()`, the variable
@@ -290,7 +290,7 @@ This would render **plugins/Users/templates/UserDetails/custom_file.php**
290290

291291
## Content Type Negotiation
292292

293-
`method` Cake\\Controller\\Controller::**addViewClasses**(array $viewClasses)
293+
`method` Cake\\Controller\\Controller::**addViewClasses**(array $viewClasses): static
294294

295295
Controllers can define a list of view classes they support. After the
296296
controller's action is complete CakePHP will use the view list to perform
@@ -462,7 +462,7 @@ a life-cycle handler.
462462

463463
## Loading Additional Tables/Models
464464

465-
`method` Cake\\Controller\\Controller::**fetchTable**(string $alias, array $config = [])
465+
`method` Cake\\Controller\\Controller::**fetchTable**(?string $alias = null, array $options = []): Table
466466

467467
The `fetchTable()` method comes handy when you need to use an ORM table that is not
468468
the controller's default one:
@@ -478,7 +478,7 @@ $recentArticles = $this->fetchTable('Articles')->find('all',
478478

479479
### fetchModel()
480480

481-
`method` Cake\\Controller\\Controller::**fetchModel**(string|null $modelClass = null, string|null $modelType = null)
481+
`method` Cake\\Controller\\Controller::**fetchModel**(?string $modelClass = null, ?string $modelType = null): object
482482

483483
The `fetchModel()` method is useful to load non ORM models or ORM tables that
484484
are not the controller's default:

docs/en/controllers/request-response.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ public function sendIcs()
823823

824824
### Setting Headers
825825

826-
`method` Cake\\Http\\Response::**withHeader**($header, $value)
826+
`method` Cake\\Http\\Response::**withHeader**(string $header, string $value): static
827827

828828
Setting headers is done with the `Cake\Http\Response::withHeader()`
829829
method. Like all of the PSR-7 interface methods, this method returns a *new*
@@ -863,7 +863,7 @@ $response = $response->withType('application/json')
863863
->withStringBody(json_encode(['Foo' => 'bar']));
864864
```
865865

866-
`method` Cake\\Http\\Response::**withBody**($body)
866+
`method` Cake\\Http\\Response::**withBody**(StreamInterface $body): static
867867

868868
To set the response body, use the `withBody()` method, which is provided by the
869869
`Laminas\Diactoros\MessageTrait`:
@@ -1193,17 +1193,17 @@ criteria are met:
11931193

11941194
The `CorsBuilder` provides the following methods for configuring CORS:
11951195

1196-
`method` Cake\\Http\\CorsBuilder::**allowOrigin**(array|string $domains)
1196+
`method` Cake\\Http\\CorsBuilder::**allowOrigin**(array|string $domains): static
11971197

1198-
`method` Cake\\Http\\CorsBuilder::**allowMethods**(array $methods)
1198+
`method` Cake\\Http\\CorsBuilder::**allowMethods**(array $methods): static
11991199

1200-
`method` Cake\\Http\\CorsBuilder::**allowHeaders**(array $headers)
1200+
`method` Cake\\Http\\CorsBuilder::**allowHeaders**(array $headers): static
12011201

1202-
`method` Cake\\Http\\CorsBuilder::**allowCredentials**()
1202+
`method` Cake\\Http\\CorsBuilder::**allowCredentials**(): static
12031203

1204-
`method` Cake\\Http\\CorsBuilder::**exposeHeaders**(array $headers)
1204+
`method` Cake\\Http\\CorsBuilder::**exposeHeaders**(array $headers): static
12051205

1206-
`method` Cake\\Http\\CorsBuilder::**maxAge**(string|int $age)
1206+
`method` Cake\\Http\\CorsBuilder::**maxAge**(string|int $age): static
12071207

12081208
`method` Cake\\Http\\CorsBuilder::**build**(): ResponseInterface
12091209

docs/en/orm/behaviors/counter-cache.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ Finally clear all caches with `bin/cake cache clear_all` and try it out.
168168

169169
## Manually updating counter caches
170170

171-
`method` Cake\\ORM\\Behavior\\CounterCacheBehavior::**updateCounterCache(?string $assocName = null, int $limit = 100, ?int $page = null): void**()
171+
`method` Cake\\ORM\\Behavior\\CounterCacheBehavior::**updateCounterCache**(?string $assocName = null, int $limit = 100, ?int $page = null): void
172172

173173
The `updateCounterCache()` method allows you to update the counter cache values
174174
for all records of one or all configured associations in batches. This can be useful,

docs/en/orm/database-basics.md

Lines changed: 3 additions & 3 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): ConnectionInterface
342+
`static` Cake\\Datasource\\ConnectionManager::**get**(string $name): ConnectionInterface
343343

344344
Once configured connections can be fetched using
345345
`Cake\Datasource\ConnectionManager::get()`. This method will
@@ -518,7 +518,7 @@ Maps to a native `DATETIME` column type. In PostgreSQL and SQL Server this
518518
turns into a `TIMESTAMP` type. The default return value of this column type is
519519
`Cake\I18n\DateTime` which extends [Chronos](https://github.com/cakephp/chronos) and the native `DateTimeImmutable`.
520520

521-
`method` Cake\\Database\\DateTimeType::**setTimezone**(string|\\DateTimeZone|null $timezone)
521+
`method` Cake\\Database\\DateTimeType::**setTimezone**(string|DateTimeZone|null $timezone): static
522522

523523
If your database server's timezone does not match your application's PHP timezone
524524
then you can use this method to specify your database's timezone. This timezone
@@ -646,7 +646,7 @@ Geospatial schema types were added.
646646

647647
`class` Cake\\Database\\**TypeFactory**
648648

649-
`static` Cake\\Database\\TypeFactory::**map**($name, $class): void
649+
`static` Cake\\Database\\TypeFactory::**map**(string $name, string $class): void
650650

651651
If you need to use vendor specific types that are not built into CakePHP you can
652652
add additional new types to CakePHP's type system. Type classes are expected to

docs/en/orm/deleting-data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ records with these method **will** trigger events.
8484

8585
### deleteAll()
8686

87-
`method` Cake\\ORM\\Table::**deleteAll**($conditions): int
87+
`method` Cake\\ORM\\Table::**deleteAll**(QueryExpression|Closure|array|string|null $conditions): int
8888

8989
There may be times when deleting rows one by one is not efficient or useful.
9090
In these cases it is more performant to use a bulk-delete to remove many rows at

docs/en/orm/entities.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ You can also use the `get()` and `set()` methods.
9797

9898
### set()
9999

100-
`method` Cake\\ORM\\Entity::**set**($field, $value = null, array $options = [])
100+
`method` Cake\\ORM\\Entity::**set**(array|string $field, mixed $value = null, array $options = []): static
101101

102102
### get()
103103

104-
`method` Cake\\ORM\\Entity::**get**($field)
104+
`method` Cake\\ORM\\Entity::**get**(string $field): mixed
105105

106106
For example:
107107

@@ -112,7 +112,7 @@ echo $article->get('title');
112112

113113
### patch()
114114

115-
`method` Cake\\ORM\\Entity::**patch**(array $fields, array $options = [])
115+
`method` Cake\\ORM\\Entity::**patch**(array $fields, array $options = []): static
116116

117117
Using `patch()` you can mass assign multiple fields at once:
118118

docs/en/orm/saving-data.md

Lines changed: 3 additions & 3 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 = []): EntityInterface|false
798+
`method` Cake\\ORM\\Table::**save**(EntityInterface $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:
@@ -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 = []): EntityInterface
1288+
`method` Cake\\ORM\\Table::**findOrCreate**(SelectQuery|callable|array $search, callable|array|null $callback = null, array $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
@@ -1371,7 +1371,7 @@ The result will be updated entities on success or `false` on failure.
13711371

13721372
## Bulk Updates
13731373

1374-
`method` Cake\\ORM\\Table::**updateAll**($fields, $conditions): int
1374+
`method` Cake\\ORM\\Table::**updateAll**(QueryExpression|Closure|array|string $fields, QueryExpression|Closure|array|string|null $conditions): int
13751375

13761376
There may be times when updating rows individually is not efficient or
13771377
necessary. In these cases it is more efficient to use a bulk-update to modify

docs/en/orm/table-objects.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,22 +273,22 @@ Behaviors, can use this hook to add in validation methods.
273273

274274
### buildRules
275275

276-
`method` Cake\\ORM\\Table::**buildRules(RulesChecker $rules): RulesChecker**()
276+
`method` Cake\\ORM\\Table::**buildRules**(RulesChecker $rules): RulesChecker
277277

278278
The `Model.buildRules` event is fired after a rules instance has been
279279
created and after the `Table::buildRules()` method has been called.
280280

281281
### beforeRules
282282

283-
`method` Cake\\ORM\\Table::**beforeRules**(EventInterface $event, EntityInterface $entity, ArrayObject $options, $operation): void
283+
`method` Cake\\ORM\\Table::**beforeRules**(EventInterface $event, EntityInterface $entity, ArrayObject $options, string $operation): void
284284

285285
The `Model.beforeRules` event is fired before an entity has had rules applied. By
286286
stopping this event, you can halt the rules checking and set the result
287287
of applying rules.
288288

289289
### afterRules
290290

291-
`method` Cake\\ORM\\Table::**afterRules**(EventInterface $event, EntityInterface $entity, ArrayObject $options, $result, $operation): void
291+
`method` Cake\\ORM\\Table::**afterRules**(EventInterface $event, EntityInterface $entity, ArrayObject $options, bool $result, string $operation): void
292292

293293
The `Model.afterRules` event is fired after an entity has rules applied. By
294294
stopping this event, you can return the final value of the rules checking
@@ -499,7 +499,7 @@ few other useful features as well.
499499

500500
### Configuring Table Objects
501501

502-
`method` Cake\\ORM\\TableLocator::**get**($alias, $config)
502+
`method` Cake\\ORM\\TableLocator::**get**(string $alias, array $options = []): Table
503503

504504
When loading tables from the registry you can customize their dependencies, or
505505
use mock objects by providing an `$options` array:

docs/en/views/helpers.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -377,24 +377,24 @@ does not implement any of the callback methods.
377377

378378
#### beforeRenderFile()
379379

380-
`method` Helper::**beforeRenderFile**(EventInterface $event, $viewFile): void
380+
`method` Helper::**beforeRenderFile**(EventInterface $event, string $viewFile): void
381381

382382
#### afterRenderFile()
383383

384-
`method` Helper::**afterRenderFile**(EventInterface $event, $viewFile, $content): void
384+
`method` Helper::**afterRenderFile**(EventInterface $event, string $viewFile, string $content): void
385385

386386
#### beforeRender()
387387

388-
`method` Helper::**beforeRender**(EventInterface $event, $viewFile): void
388+
`method` Helper::**beforeRender**(EventInterface $event, string $viewFile): void
389389

390390
#### afterRender()
391391

392-
`method` Helper::**afterRender**(EventInterface $event, $viewFile): void
392+
`method` Helper::**afterRender**(EventInterface $event, string $viewFile): void
393393

394394
#### beforeLayout()
395395

396-
`method` Helper::**beforeLayout**(EventInterface $event, $layoutFile): void
396+
`method` Helper::**beforeLayout**(EventInterface $event, string $layoutFile): void
397397

398398
#### afterLayout()
399399

400-
`method` Helper::**afterLayout**(EventInterface $event, $layoutFile): void
400+
`method` Helper::**afterLayout**(EventInterface $event, string $layoutFile): void

0 commit comments

Comments
 (0)