From 8ae2a46aea65583941ab589ae41cc9f4b9a8cc42 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 13 Nov 2024 14:36:06 -0500 Subject: [PATCH] Start rector set for 5.2 (#300) - Add rector for Argument::getMultipleOption() --- config/rector/cakephp52.php | 9 +++++++++ config/rector/sets/cakephp52.php | 13 +++++++++++++ src/Rector/Set/CakePHPSetList.php | 5 +++++ tests/TestCase/Command/RectorCommandTest.php | 7 +++++++ .../RectorCommand-testApply52/src/SomeTest.php | 15 +++++++++++++++ .../RectorCommand-testApply52/src/SomeTest.php | 15 +++++++++++++++ 6 files changed, 64 insertions(+) create mode 100644 config/rector/cakephp52.php create mode 100644 config/rector/sets/cakephp52.php create mode 100644 tests/test_apps/original/RectorCommand-testApply52/src/SomeTest.php create mode 100644 tests/test_apps/upgraded/RectorCommand-testApply52/src/SomeTest.php diff --git a/config/rector/cakephp52.php b/config/rector/cakephp52.php new file mode 100644 index 0000000..49e95ee --- /dev/null +++ b/config/rector/cakephp52.php @@ -0,0 +1,9 @@ +sets([CakePHPSetList::CAKEPHP_52]); +}; diff --git a/config/rector/sets/cakephp52.php b/config/rector/sets/cakephp52.php new file mode 100644 index 0000000..2995218 --- /dev/null +++ b/config/rector/sets/cakephp52.php @@ -0,0 +1,13 @@ +ruleWithConfiguration(RenameMethodRector::class, [ + new MethodCallRename('Cake\Console\Arguments', 'getMultipleOption', 'getArrayOption'), + ]); +}; diff --git a/src/Rector/Set/CakePHPSetList.php b/src/Rector/Set/CakePHPSetList.php index ff149d9..eb4c368 100644 --- a/src/Rector/Set/CakePHPSetList.php +++ b/src/Rector/Set/CakePHPSetList.php @@ -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 */ diff --git a/tests/TestCase/Command/RectorCommandTest.php b/tests/TestCase/Command/RectorCommandTest.php index 4b27913..d109ee4 100644 --- a/tests/TestCase/Command/RectorCommandTest.php +++ b/tests/TestCase/Command/RectorCommandTest.php @@ -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(); + } } diff --git a/tests/test_apps/original/RectorCommand-testApply52/src/SomeTest.php b/tests/test_apps/original/RectorCommand-testApply52/src/SomeTest.php new file mode 100644 index 0000000..ef14d99 --- /dev/null +++ b/tests/test_apps/original/RectorCommand-testApply52/src/SomeTest.php @@ -0,0 +1,15 @@ + [1, 2]], []); + $option = $args->getMultipleOption('a'); + } +} diff --git a/tests/test_apps/upgraded/RectorCommand-testApply52/src/SomeTest.php b/tests/test_apps/upgraded/RectorCommand-testApply52/src/SomeTest.php new file mode 100644 index 0000000..713e0dd --- /dev/null +++ b/tests/test_apps/upgraded/RectorCommand-testApply52/src/SomeTest.php @@ -0,0 +1,15 @@ + [1, 2]], []); + $option = $args->getArrayOption('a'); + } +}