Skip to content

Commit 7f2b457

Browse files
authored
Merge pull request #327 from cakephp/5.x-orm-query
add rector to transform ORM\Query to ORM\Query\SelectQuery
2 parents 7e7e2cb + b896c0c commit 7f2b457

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

config/rector/sets/cakephp53.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
use Cake\Upgrade\Rector\Rector\MethodCall\EntityIsEmptyRector;
55
use Rector\Config\RectorConfig;
66
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
7+
use Rector\Renaming\Rector\Name\RenameClassRector;
78
use Rector\Renaming\ValueObject\MethodCallRename;
89

910
# @see https://book.cakephp.org/5/en/appendices/5-3-migration-guide.html
1011
return static function (RectorConfig $rectorConfig): void {
1112
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
1213
new MethodCallRename('Cake\Database\Query', 'newExpr', 'expr'),
1314
]);
15+
$rectorConfig->ruleWithConfiguration(RenameClassRector::class, [
16+
'Cake\ORM\Query' => 'Cake\ORM\Query\SelectQuery',
17+
]);
1418
$rectorConfig->rule(EntityIsEmptyRector::class);
1519
};

phpcs.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?xml version="1.0"?>
22
<ruleset name="CakePHP Upgrade">
3-
<config name="installed_paths" value="../../cakephp/cakephp-codesniffer"/>
4-
53
<rule ref="CakePHP"/>
64

75
<exclude-pattern>tests/test_apps</exclude-pattern>

tests/test_apps/original/RectorCommand-testApply53/src/SomeTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use Cake\ORM\Entity;
77
use Cake\ORM\Locator\LocatorAwareTrait;
8+
use Cake\ORM\Query;
89

910
class SomeTest
1011
{
@@ -18,4 +19,8 @@ public function testRenames(): void
1819
$table = $this->fetchTable('Articles');
1920
$expr = $table->find()->newExpr();
2021
}
22+
23+
public function findSomething(Query $query, array $options): Query {
24+
return $query;
25+
}
2126
}

tests/test_apps/upgraded/RectorCommand-testApply53/src/SomeTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use Cake\ORM\Entity;
77
use Cake\ORM\Locator\LocatorAwareTrait;
8+
use Cake\ORM\Query;
89

910
class SomeTest
1011
{
@@ -18,4 +19,8 @@ public function testRenames(): void
1819
$table = $this->fetchTable('Articles');
1920
$expr = $table->find()->expr();
2021
}
22+
23+
public function findSomething(\Cake\ORM\Query\SelectQuery $query, array $options): \Cake\ORM\Query\SelectQuery {
24+
return $query;
25+
}
2126
}

0 commit comments

Comments
 (0)