Skip to content

Commit 31832e9

Browse files
committed
prepare for 4.2.0
1 parent f223985 commit 31832e9

3 files changed

Lines changed: 71 additions & 1 deletion

File tree

.semver

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
22
:major: 4
3-
:minor: 0
3+
:minor: 2
44
:patch: 0
55
:special: ''

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Changelog
2+
3+
## 4.2.0 (2026-04-10)
4+
5+
### New Features
6+
7+
- **`SelectQueryFindListReturnTypeExtension`**: Provides proper return type inference for `find('list')->toArray()`, returning `array<int|string, string>` instead of the generic entity array type. Works with chained queries (`where()`, `orderBy()`, `limit()`, etc.).
8+
- **`groupField` support for `find('list')`**: When `groupField` is provided to `find('list')`, the return type is correctly inferred as `array<int|string, array<int|string, string>>`.
9+
- **Custom application namespace**: Support for defining a custom application namespace via the `cakeDC.appNamespace` configuration parameter (defaults to `App`).
10+
11+
### Improvements
12+
13+
- Made constructor dependency in rules/extensions optional to preserve backwards compatibility; instances self-instantiate if none is provided.
14+
15+
## 4.1.1 (2025-11-13)
16+
17+
### Improvements
18+
19+
- `DisallowEntityArrayAccessRule`: ignore custom (non-integer) array access keys, allowing legitimate use cases.
20+
21+
## 4.1.0
22+
23+
### New Features
24+
25+
- Added `ControllerMethodMustBeUsedRule`: enforces that `render()` and `redirect()` must be used (returned or assigned) to prevent unreachable code.
26+
27+
## 4.0.0
28+
29+
### Breaking Changes
30+
31+
- Requires CakePHP 5.x and PHPStan 2.x.
32+
33+
## 3.x
34+
35+
See git history for older changes.

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,27 @@ Features included:
4646
1. Provide correct return type for `Cake\Console\ConsoleIo::helper()`
4747

4848
# Table class return type extensions
49+
### SelectQueryFindListReturnTypeExtension
50+
Provides proper return type for `find('list')->toArray()`:
51+
1. Returns `array<int|string, string>` for `find('list')->toArray()` instead of the generic entity array
52+
1. Returns `array<int|string, array<int|string, string>>` when `groupField` is provided
53+
1. Works with chained queries: `find('list')->where([...])->orderBy([...])->toArray()`
54+
55+
<details>
56+
<summary>Examples:</summary>
57+
58+
```php
59+
// PHPStan now knows the return type is array<int|string, string>
60+
$roles = $this->Roles->find('list')->toArray();
61+
62+
// PHPStan now knows the return type is array<int|string, string> (chained)
63+
$roles = $this->Roles->find('list')->where(['active' => true])->orderBy(['name' => 'ASC'])->toArray();
64+
65+
// PHPStan now knows the return type is array<int|string, array<int|string, string>> (grouped)
66+
$roles = $this->Roles->find('list', groupField: 'category_id')->toArray();
67+
```
68+
</details>
69+
4970
### TableEntityDynamicReturnTypeExtension
5071
1. Provide correct return type for `Cake\ORM\Table::get` based on your table class name
5172
1. Provide correct return type for `Cake\ORM\Table::newEntity` based on your table class name
@@ -216,6 +237,20 @@ parameters:
216237
addAssociationExistsTableClassRule: false
217238
```
218239

240+
# Configuration
241+
242+
### Custom application namespace
243+
244+
By default, this extension assumes your application uses the `App` namespace. If your application uses a custom namespace, configure it with the `appNamespace` parameter:
245+
246+
```
247+
parameters:
248+
cakeDC:
249+
appNamespace: MyApp
250+
```
251+
252+
This affects class resolution in rules and type extensions (e.g. `MyApp\Model\Table\UsersTable` instead of `App\Model\Table\UsersTable`).
253+
219254
# PHPDoc Extensions
220255
### TableAssociationTypeNodeResolverExtension
221256
Fix intersection association phpDoc to correct generic object type, ex:

0 commit comments

Comments
 (0)