Skip to content

Commit 2c8f49d

Browse files
dereuromarkjosbeir
andauthored
Fix critical method signature mismatches with 5.x source (#8179)
Fixes method signatures that were wrong, referenced nonexistent methods, or had extra/missing parameters compared to the actual CakePHP 5.x source code. Relates to #7744. Changes: - Entity::dirty() -> isDirty() (dirty() does not exist in 5.x) - Table::get() updated to match new named-parameter signature - Table::find() add type and default for $type parameter - RouteBuilder::extensions() -> setExtensions() (extensions() does not exist) - PaginatorHelper::counter() remove nonexistent $options parameter - PaginatorHelper::generateUrl() remove nonexistent $model parameter - PaginatorHelper::hasNext() remove nonexistent $model parameter - Controller::addViewClasses() add missing $viewClasses parameter - Cache::add() fix syntax error (missing comma) and add types Co-authored-by: Jasper Smet <josbeir@users.noreply.github.com>
1 parent 1f20739 commit 2c8f49d

6 files changed

Lines changed: 15 additions & 24 deletions

File tree

docs/en/controllers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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**()
293+
`method` Cake\\Controller\\Controller::**addViewClasses**(array $viewClasses)
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

docs/en/core-libraries/caching.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ $result = Cache::writeMany([
326326

327327
### Cache::add()
328328

329-
`static` Cake\\Cache\\Cache::**add**($key, $value $config = 'default')
329+
`static` Cake\\Cache\\Cache::**add**(string $key, mixed $value, string $config = 'default')
330330

331331
Using `Cache::add()` will let you atomically set a key to a value if the key
332332
does not already exist in the cache. If the key already exists in the cache

docs/en/development/routing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ file extensions
10251025

10261026
### Routing File Extensions
10271027

1028-
`static` Cake\\Routing\\RouteBuilder::**extensions**(stringnull $extensions, $merge = true)
1028+
`method` Cake\\Routing\\RouteBuilder::**setExtensions**(array|string $extensions)
10291029

10301030
To handle different file extensions in your URLs, you can define the extensions
10311031
using the `Cake\Routing\RouteBuilder::setExtensions()` method:

docs/en/orm/entities.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ see [Exposing Virtual Fields](#exposing-virtual-fields).
304304

305305
## Checking if an Entity Has Been Modified
306306

307-
`method` Cake\\ORM\\Entity::**dirty**($field = null, $dirty = null)
307+
`method` Cake\\ORM\\Entity::**isDirty**(?string $field = null)
308308

309309
You may want to make code conditional based on whether or not fields have
310310
changed in an entity. For example, you may only want to validate fields when

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

Lines changed: 8 additions & 17 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**($id, $options = [])
28+
`method` Cake\\ORM\\Table::**get**(mixed $primaryKey, array|string $finder = 'all', CacheInterface|string|null $cache = null, Closure|string|null $cacheKey = null, mixed ...$args)
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()`:
@@ -69,26 +69,17 @@ by using the `finder` option:
6969
$article = $articles->get($id, 'translations');
7070
```
7171

72-
The list of options supported by get() are:
72+
The parameters supported by `get()` are:
7373

74-
- `cache` cache config.
75-
- `key` cache key.
76-
- `finder` custom finder function.
77-
- `conditions` provide conditions for the WHERE clause of your query.
78-
- `limit` Set the number of rows you want.
79-
- `offset` Set the page offset you want. You can also use `page` to make
80-
the calculation simpler.
81-
- `contain` define the associations to eager load.
82-
- `fields` limit the fields loaded into the entity. Only loading some fields
83-
can cause entities to behave incorrectly.
84-
- `group` add a GROUP BY clause to your query. This is useful when using
85-
aggregating functions.
86-
- `having` add a HAVING clause to your query.
87-
- `join` define additional custom joins.
74+
- `$primaryKey` The primary key value to look up.
75+
- `$finder` The finder to use. Can be a string finder name or an array of finder name and options.
76+
- `$cache` A cache config name or `CacheInterface` instance to use for read-through caching.
77+
- `$cacheKey` A custom cache key or `Closure` to generate one.
78+
- `...$args` Additional arguments passed to the finder.
8879

8980
## Using Finders to Load Data
9081

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

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

docs/en/views/helpers/paginator.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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)
289+
`method` Cake\\View\\Helper\\PaginatorHelper::**hasNext**()
290290

291291
#### hasPrev()
292292

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

303303
### Creating a Page Counter
304304

305-
`method` Cake\\View\\Helper\\PaginatorHelper::**counter**(string $format = 'pages', array $options = [])
305+
`method` Cake\\View\\Helper\\PaginatorHelper::**counter**(string $format = 'pages')
306306

307307
Returns a counter string for the paged result set. Using a provided format
308308
string and a number of options you can create localized and application
@@ -340,7 +340,7 @@ echo $this->Paginator->counter('range');
340340

341341
### Generating Pagination URLs
342342

343-
`method` Cake\\View\\Helper\\PaginatorHelper::**generateUrl**(array $options = [], ?string $model = null, array $url = [], array $urlOptions = [])
343+
`method` Cake\\View\\Helper\\PaginatorHelper::**generateUrl**(array $options = [], array $url = [], array $urlOptions = [])
344344

345345
By default returns a full pagination URL string for use in non-standard contexts
346346
(i.e. JavaScript). :

0 commit comments

Comments
 (0)