Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add rector to transform ->group() to ->groupBy() #293

Merged
merged 1 commit into from
Sep 6, 2024
Merged
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
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
Loading