Skip to content

Rename QueryExpression comparisons for CakePHP 6 - #418

Merged
LordSimal merged 2 commits into
6.xfrom
feature/query-expression-comparison-names
Nov 9, 2026
Merged

LordSimal merged 2 commits into
6.xfrom
feature/query-expression-comparison-names

Conversation

@josbeir

@josbeir josbeir commented Nov 9, 2026 •

Copy link
Copy Markdown

Extend the cakephp60 ruleset to rename QueryExpression comparisons to the full names used by the predicate functions and the fluent CakePHP 6 API.

Before:

use Cake\Database\Expression\QueryExpression;

$query->where(function (QueryExpression $exp) {
    return $exp
        ->gte('views', 1000)
        ->lt('price', 50);
});

After:

$query->where(function (QueryExpression $exp) {
    return $exp
        ->greaterThanOrEquals('views', 1000)
        ->lessThan('price', 50);
});
Previous method New method
eq() equals()
notEq() notEquals()
gt() greaterThan()
gte() greaterThanOrEquals()
lt() lessThan()
lte() lessThanOrEquals()

The configuration uses Rector's existing method-renaming rule. It handles typed QueryExpression calls, chained and nullsafe calls, first-class method callables, and subclass overrides with parent calls. Arguments and binding types are preserved. Unrelated classes and receivers whose type cannot be determined are left unchanged.

Run the rule while the old CakePHP dependency is still installed:

bin/cake upgrade rector --rules cakephp60 /path/to/your/app/src
bin/cake upgrade rector --rules cakephp60 /path/to/your/app/tests

Review dynamic method names and string-based callbacks manually.

Companion framework change: cakephp/cakephp#19778, following the predicate names introduced in cakephp/cakephp#19736.

@LordSimal
LordSimal merged commit 05e0de3 into 6.x Nov 9, 2026
5 checks passed
@LordSimal
LordSimal deleted the feature/query-expression-comparison-names branch November 9, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants