Skip to content

Commit

Permalink
Start rector set for 5.2 (#300)
Browse files Browse the repository at this point in the history
- Add rector for Argument::getMultipleOption()
  • Loading branch information
markstory authored Nov 13, 2024
1 parent aa8d73e commit 8ae2a46
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 0 deletions.
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');
}
}

0 comments on commit 8ae2a46

Please sign in to comment.