Skip to content

Commit

Permalink
add rector to transform ->group() to ->groupBy() (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
LordSimal authored Sep 6, 2024
1 parent 670a512 commit d31c3b0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
5 changes: 2 additions & 3 deletions config/rector/sets/cakephp50.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Cake\Upgrade\Rector\ValueObject\RemoveMethodCall;
use PHPStan\Type\ArrayType;
use PHPStan\Type\BooleanType;
use PHPStan\Type\IntegerType;
use PHPStan\Type\MixedType;
use PHPStan\Type\NullType;
use PHPStan\Type\StringType;
Expand All @@ -16,10 +15,8 @@
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\Rector\Name\RenameClassRector;
use Rector\Renaming\ValueObject\MethodCallRename;
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
use Rector\TypeDeclaration\Rector\Property\AddPropertyTypeDeclarationRector;
use Rector\TypeDeclaration\ValueObject\AddPropertyTypeDeclaration;
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;

# @see https://book.cakephp.org/5/en/appendices/5-0-migration-guide.html
return static function (RectorConfig $rectorConfig): void {
Expand Down Expand Up @@ -108,6 +105,8 @@
new MethodCallRename('Cake\Database\Query', 'order', 'orderBy'),
new MethodCallRename('Cake\Database\Query', 'orderAsc', 'orderByAsc'),
new MethodCallRename('Cake\Database\Query', 'orderDesc', 'orderByDesc'),
new MethodCallRename('Cake\Database\Query', 'group', 'groupBy'),
new MethodCallRename('Cake\Database\Query\SelectQuery', 'group', 'groupBy'),
]);

$rectorConfig->ruleWithConfiguration(RemoveMethodCallRector::class, [
Expand Down
1 change: 0 additions & 1 deletion tests/TestCase/Command/RectorCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public function testApplyAppDir()
{
$this->setupTestApp(__FUNCTION__);
$this->exec('upgrade rector --rules cakephp40 --dry-run ' . TEST_APP);
debug($this->_out->messages());

$this->assertExitSuccess();
$this->assertOutputContains('HelloCommand.php');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ public function finders() {
$query->find('list', ['fields' => ['id', 'title']])
->order('id')
->orderAsc('id')
->orderDesc('id');
->orderDesc('id')
->group('id');

$articles->query()
->order('id')
->orderAsc('id')
->orderDesc('id');
->orderDesc('id')
->group('id');

$article = $articles->get(1, ['key' => 'cache-key', 'contain' => ['Users']]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ public function finders() {
$query->find('list', fields: ['id', 'title'])
->orderBy('id')
->orderByAsc('id')
->orderByDesc('id');
->orderByDesc('id')
->groupBy('id');

$articles->query()
->orderBy('id')
->orderByAsc('id')
->orderByDesc('id');
->orderByDesc('id')
->groupBy('id');

$article = $articles->get(1, cacheKey: 'cache-key', contain: ['Users']);
}
Expand Down

0 comments on commit d31c3b0

Please sign in to comment.