From b93a879c46e0fa614377dd9ab1e67de67b330523 Mon Sep 17 00:00:00 2001 From: ADmad Date: Thu, 18 Sep 2025 13:03:13 +0530 Subject: [PATCH 1/2] Rename Query::newExpr() to Query::expr() Refs cakephp/cakephp#18916 --- config/rector/sets/cakephp53.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/rector/sets/cakephp53.php b/config/rector/sets/cakephp53.php index 743c554f..518f53b1 100644 --- a/config/rector/sets/cakephp53.php +++ b/config/rector/sets/cakephp53.php @@ -3,8 +3,13 @@ use Cake\Upgrade\Rector\Rector\MethodCall\EntityIsEmptyRector; use Rector\Config\RectorConfig; +use Rector\Renaming\Rector\MethodCall\RenameMethodRector; +use Rector\Renaming\ValueObject\MethodCallRename; # @see https://book.cakephp.org/5/en/appendices/5-3-migration-guide.html return static function (RectorConfig $rectorConfig): void { + $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ + new MethodCallRename('Cake\Database\Query', 'newExpr', 'expr'), + ]); $rectorConfig->rule(EntityIsEmptyRector::class); }; From 7d5724667fd9e24f7408bda0d0e18dcfff23fe95 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Thu, 18 Sep 2025 09:55:59 +0200 Subject: [PATCH 2/2] add tests --- .../original/RectorCommand-testApply53/src/SomeTest.php | 6 ++++++ .../upgraded/RectorCommand-testApply53/src/SomeTest.php | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/tests/test_apps/original/RectorCommand-testApply53/src/SomeTest.php b/tests/test_apps/original/RectorCommand-testApply53/src/SomeTest.php index a6879e22..d47952f0 100644 --- a/tests/test_apps/original/RectorCommand-testApply53/src/SomeTest.php +++ b/tests/test_apps/original/RectorCommand-testApply53/src/SomeTest.php @@ -4,12 +4,18 @@ namespace MyPlugin; use Cake\ORM\Entity; +use Cake\ORM\Locator\LocatorAwareTrait; class SomeTest { + use LocatorAwareTrait; + public function testRenames(): void { $entity = new Entity(); $result = $entity->isEmpty('test'); + + $table = $this->fetchTable('Articles'); + $expr = $table->find()->newExpr(); } } diff --git a/tests/test_apps/upgraded/RectorCommand-testApply53/src/SomeTest.php b/tests/test_apps/upgraded/RectorCommand-testApply53/src/SomeTest.php index 00172c06..1af58761 100644 --- a/tests/test_apps/upgraded/RectorCommand-testApply53/src/SomeTest.php +++ b/tests/test_apps/upgraded/RectorCommand-testApply53/src/SomeTest.php @@ -4,12 +4,18 @@ namespace MyPlugin; use Cake\ORM\Entity; +use Cake\ORM\Locator\LocatorAwareTrait; class SomeTest { + use LocatorAwareTrait; + public function testRenames(): void { $entity = new Entity(); $result = !$entity->hasValue('test'); + + $table = $this->fetchTable('Articles'); + $expr = $table->find()->expr(); } }