Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,22 @@ To install dev-dependencies use `composer setup`. Then you will be able to
run `composer test` and `composer cs-check` etc.

See also `Makefile` for more shortcut commands.

### CakePHP 6 condition predicates

The `cakephp60` ruleset replaces operator-bearing query condition keys with
namespaced predicates, for example `'id >' => $minimum` becomes
`'id' => greaterThan($minimum)` with a grouped `use function` declaration. Plain equality and boolean
arrays remain supported, as does the fluent expression builder.

Conversions are limited to known CakePHP condition consumers. Inline conditions,
callback return arrays, and local arrays whose reads are exclusively condition
arguments can be converted. Repeated fields are kept in separate nested arrays.
Nullable `IS` and `IS NOT` use `equals()` and `notEquals()`, preserving their runtime choice
between a null check and an ordinary comparison. Custom recognized operators use
`comparison()`, whose operator argument remains trusted SQL.

Review dynamically constructed keys, shared condition/configuration arrays,
arrays assembled incrementally, and custom condition consumers manually. The rule
leaves ambiguous arrays unchanged rather than changing unrelated application data.
Run the tool before upgrading application dependencies to CakePHP 6.
3 changes: 3 additions & 0 deletions config/rector/sets/cakephp60.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use Cake\Upgrade\Rector\Cake6\BinaryColumnToVarbinaryRector;
use Cake\Upgrade\Rector\Cake6\BreadcrumbsHelperTitleToContentRector;
use Cake\Upgrade\Rector\Cake6\ConditionOperatorsToPredicatesRector;
use Cake\Upgrade\Rector\Cake6\EventManagerOnRector;
use Cake\Upgrade\Rector\Cake6\RemoveAssignmentFromVoidMethodRector;
use Cake\Upgrade\Rector\Cake6\ReplaceCommandArgsIoWithPropertiesRector;
Expand All @@ -25,6 +26,8 @@

# @see https://book.cakephp.org/6/en/appendices/6-0-migration-guide.html
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rule(ConditionOperatorsToPredicatesRector::class);

// EventManager::on() signature change
$rectorConfig->rule(EventManagerOnRector::class);

Expand Down
Loading
Loading