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

Start rector set for 5.2 #300

Merged
merged 2 commits into from
Nov 13, 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
9 changes: 9 additions & 0 deletions config/rector/cakephp52.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
declare(strict_types=1);

use Cake\Upgrade\Rector\Set\CakePHPSetList;
use Rector\Config\RectorConfig;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->sets([CakePHPSetList::CAKEPHP_52]);
};
13 changes: 13 additions & 0 deletions config/rector/sets/cakephp52.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\ValueObject\MethodCallRename;

# @see https://book.cakephp.org/5/en/appendices/5-2-migration-guide.html
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
new MethodCallRename('Cake\Console\Arguments', 'getMultipleOption', 'getArrayOption'),
]);
};
5 changes: 5 additions & 0 deletions src/Rector/Set/CakePHPSetList.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ final class CakePHPSetList implements SetListInterface
*/
public const CAKEPHP_51 = __DIR__ . '/../../../config/rector/sets/cakephp51.php';

/**
* @var string
*/
public const CAKEPHP_52 = __DIR__ . '/../../../config/rector/sets/cakephp52.php';

/**
* @var string
*/
Expand Down
7 changes: 7 additions & 0 deletions tests/TestCase/Command/RectorCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,11 @@ public function testApply51()
$this->exec('upgrade rector --rules cakephp51 ' . TEST_APP);
$this->assertTestAppUpgraded();
}

public function testApply52()
{
$this->setupTestApp(__FUNCTION__);
$this->exec('upgrade rector --rules cakephp52 ' . TEST_APP);
$this->assertTestAppUpgraded();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);

namespace MyPlugin;

use Cake\Console\Arguments;

class SomeTest extends TestCase
{
public function testRenames(): void
{
$args = new Arguments([], ['a' => [1, 2]], []);
$option = $args->getMultipleOption('a');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);

namespace MyPlugin;

use Cake\Console\Arguments;

class SomeTest extends TestCase
{
public function testRenames(): void
{
$args = new Arguments([], ['a' => [1, 2]], []);
$option = $args->getArrayOption('a');
}
}
Loading