From cc794711ad091d0706469a820f9f45a647baf441 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Sun, 3 May 2020 23:23:32 +0200 Subject: [PATCH] [CakePHP to Symfony] Deprecate unfinished set --- composer.json | 4 - .../cakephp-24-to-symfony-51.yaml | 20 -- docs/rector_rules_overview.md | 323 +----------------- rules/cakephp-to-symfony/config/config.yaml | 9 - ...toryFindMethodCallManipulatorInterface.php | 14 - .../src/NodeFactory/DoctrineNodeFactory.php | 85 ----- .../EventSubscriberClassFactory.php | 104 ------ .../NodeFactory/RelationPropertyFactory.php | 175 ---------- ...ctrineRepositoryClassMethodManipulator.php | 87 ----- ...actRepositoryFindMethodCallManipulator.php | 101 ------ ...AllRepositoryFindMethodCallManipulator.php | 25 -- ...untRepositoryFindMethodCallManipulator.php | 32 -- ...rstRepositoryFindMethodCallManipulator.php | 69 ---- ...istRepositoryFindMethodCallManipulator.php | 45 --- ...dedRepositoryFindMethodCallManipulator.php | 33 -- .../src/Rector/AbstractCakePHPRector.php | 22 -- ...rActionToSymfonyControllerActionRector.php | 80 ----- ...kePHPControllerRedirectToSymfonyRector.php | 151 -------- ...CakePHPControllerRenderToSymfonyRector.php | 215 ------------ ...reFilterToRequestEventSubscriberRector.php | 94 ----- ...ePHPControllerComponentToSymfonyRector.php | 186 ---------- ...CakePHPControllerHelperToSymfonyRector.php | 118 ------- ...PHPControllerToSymfonyControllerRector.php | 73 ---- ...itRouteToExplicitRouteAnnotationRector.php | 116 ------- .../CakePHPModelToDoctrineEntityRector.php | 152 --------- ...CakePHPModelToDoctrineRepositoryRector.php | 268 --------------- .../Echo_/CakePHPTemplateHToTwigRector.php | 66 ---- .../Echo_/CakePHPTemplateLinkToTwigRector.php | 129 ------- .../CakePHPTemplateTranslateToTwigRector.php | 56 --- .../cakephp-to-symfony/src/RouteResolver.php | 41 --- .../TemplateMethodCallManipulator.php | 130 ------- .../src/TemplatePathResolver.php | 112 ------ ...ionToSymfonyControllerActionRectorTest.php | 30 -- .../Fixture/fixture.php.inc | 27 -- ...PControllerRedirectToSymfonyRectorTest.php | 30 -- .../Fixture/fixture.php.inc | 27 -- .../Fixture/redirect_to_controller.php.inc | 30 -- ...PHPControllerRenderToSymfonyRectorTest.php | 30 -- .../Fixture/changed_view_property.php.inc | 27 -- .../Fixture/compact_too.php.inc | 27 -- .../Fixture/fixture.php.inc | 27 -- .../Fixture/set.php.inc | 27 -- ...oRequestEventSubscriberRectorExtraTest.php | 35 -- .../Fixture/fixture.php.inc | 23 -- .../Source/extra_file.php | 15 - .../Source/extra_file_after.php | 22 -- ...ControllerComponentToSymfonyRectorTest.php | 30 -- .../Fixture/fixture.php.inc | 51 --- .../Source/Component.php | 8 - ...PHPControllerHelperToSymfonyRectorTest.php | 30 -- .../Fixture/fixture.php.inc | 31 -- ...ontrollerToSymfonyControllerRectorTest.php | 30 -- .../Fixture/fixture.php.inc | 25 -- ...uteToExplicitRouteAnnotationRectorTest.php | 30 -- .../Fixture/fixture.php.inc | 29 -- .../Fixture/skip_private.php.inc | 10 - ...CakePHPModelToDoctrineEntityRectorTest.php | 30 -- .../Fixture/belongs_to.php.inc | 35 -- .../Fixture/has_many.php.inc | 32 -- .../has_many_and_belongs_to_many.php.inc | 32 -- .../Fixture/has_one.php.inc | 32 -- .../Source/AppModel.php | 8 - ...PHPModelToDoctrineRepositoryRectorTest.php | 68 ---- .../Fixture/find_all.php.inc | 25 -- .../Fixture/find_count.php.inc | 25 -- .../Fixture/find_first.php.inc | 33 -- .../Fixture/find_list.php.inc | 23 -- .../find_list_with_one_argument.php.inc | 25 -- .../Fixture/find_threaded.php.inc | 25 -- .../Source/ExpectedFindAllRepository.php | 20 -- .../Source/ExpectedFindCountRepository.php | 19 -- .../Source/ExpectedFindFirstRepository.php | 20 -- .../Source/ExpectedFindListRepository.php | 19 -- ...ectedFindListWithOneArgumentRepository.php | 19 -- .../Source/ExpectedFindThreadedRepository.php | 19 -- .../CakePHPTemplateHToTwigRectorTest.php | 30 -- .../Fixture/html_fixture.php.inc | 3 - .../CakePHPTemplateToTwigRectorTest.php | 30 -- .../Fixture/fixture.php.inc | 7 - ...kePHPTemplateTranslateToTwigRectorTest.php | 30 -- .../Fixture/fixture.php.inc | 3 - .../Node/Manipulator/ClassManipulator.php | 34 +- .../Manipulator/PropertyFetchManipulator.php | 20 -- 83 files changed, 2 insertions(+), 4450 deletions(-) delete mode 100644 config/set/cakephp-to-symfony/cakephp-24-to-symfony-51.yaml delete mode 100644 rules/cakephp-to-symfony/config/config.yaml delete mode 100644 rules/cakephp-to-symfony/src/Contract/NodeManipulator/RepositoryFindMethodCallManipulatorInterface.php delete mode 100644 rules/cakephp-to-symfony/src/NodeFactory/DoctrineNodeFactory.php delete mode 100644 rules/cakephp-to-symfony/src/NodeFactory/EventSubscriberClassFactory.php delete mode 100644 rules/cakephp-to-symfony/src/NodeFactory/RelationPropertyFactory.php delete mode 100644 rules/cakephp-to-symfony/src/NodeManipulator/DoctrineRepositoryClassMethodManipulator.php delete mode 100644 rules/cakephp-to-symfony/src/NodeManipulator/RepositoryFindClassMethodManipulator/AbstractRepositoryFindMethodCallManipulator.php delete mode 100644 rules/cakephp-to-symfony/src/NodeManipulator/RepositoryFindClassMethodManipulator/FindAllRepositoryFindMethodCallManipulator.php delete mode 100644 rules/cakephp-to-symfony/src/NodeManipulator/RepositoryFindClassMethodManipulator/FindCountRepositoryFindMethodCallManipulator.php delete mode 100644 rules/cakephp-to-symfony/src/NodeManipulator/RepositoryFindClassMethodManipulator/FindFirstRepositoryFindMethodCallManipulator.php delete mode 100644 rules/cakephp-to-symfony/src/NodeManipulator/RepositoryFindClassMethodManipulator/FindListRepositoryFindMethodCallManipulator.php delete mode 100644 rules/cakephp-to-symfony/src/NodeManipulator/RepositoryFindClassMethodManipulator/FindThreadedRepositoryFindMethodCallManipulator.php delete mode 100644 rules/cakephp-to-symfony/src/Rector/AbstractCakePHPRector.php delete mode 100644 rules/cakephp-to-symfony/src/Rector/ClassMethod/CakePHPControllerActionToSymfonyControllerActionRector.php delete mode 100644 rules/cakephp-to-symfony/src/Rector/ClassMethod/CakePHPControllerRedirectToSymfonyRector.php delete mode 100644 rules/cakephp-to-symfony/src/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector.php delete mode 100644 rules/cakephp-to-symfony/src/Rector/Class_/CakePHPBeforeFilterToRequestEventSubscriberRector.php delete mode 100644 rules/cakephp-to-symfony/src/Rector/Class_/CakePHPControllerComponentToSymfonyRector.php delete mode 100644 rules/cakephp-to-symfony/src/Rector/Class_/CakePHPControllerHelperToSymfonyRector.php delete mode 100644 rules/cakephp-to-symfony/src/Rector/Class_/CakePHPControllerToSymfonyControllerRector.php delete mode 100644 rules/cakephp-to-symfony/src/Rector/Class_/CakePHPImplicitRouteToExplicitRouteAnnotationRector.php delete mode 100644 rules/cakephp-to-symfony/src/Rector/Class_/CakePHPModelToDoctrineEntityRector.php delete mode 100644 rules/cakephp-to-symfony/src/Rector/Class_/CakePHPModelToDoctrineRepositoryRector.php delete mode 100644 rules/cakephp-to-symfony/src/Rector/Echo_/CakePHPTemplateHToTwigRector.php delete mode 100644 rules/cakephp-to-symfony/src/Rector/Echo_/CakePHPTemplateLinkToTwigRector.php delete mode 100644 rules/cakephp-to-symfony/src/Rector/Echo_/CakePHPTemplateTranslateToTwigRector.php delete mode 100644 rules/cakephp-to-symfony/src/RouteResolver.php delete mode 100644 rules/cakephp-to-symfony/src/Template/TemplateMethodCallManipulator.php delete mode 100644 rules/cakephp-to-symfony/src/TemplatePathResolver.php delete mode 100644 rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerActionToSymfonyControllerActionRector/CakePHPControllerActionToSymfonyControllerActionRectorTest.php delete mode 100644 rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerActionToSymfonyControllerActionRector/Fixture/fixture.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRedirectToSymfonyRector/CakePHPControllerRedirectToSymfonyRectorTest.php delete mode 100644 rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRedirectToSymfonyRector/Fixture/fixture.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRedirectToSymfonyRector/Fixture/redirect_to_controller.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector/CakePHPControllerRenderToSymfonyRectorTest.php delete mode 100644 rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector/Fixture/changed_view_property.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector/Fixture/compact_too.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector/Fixture/fixture.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector/Fixture/set.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPBeforeFilterToRequestEventSubscriberRector/CakePHPBeforeFilterToRequestEventSubscriberRectorExtraTest.php delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPBeforeFilterToRequestEventSubscriberRector/Fixture/fixture.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPBeforeFilterToRequestEventSubscriberRector/Source/extra_file.php delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPBeforeFilterToRequestEventSubscriberRector/Source/extra_file_after.php delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerComponentToSymfonyRector/CakePHPControllerComponentToSymfonyRectorTest.php delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerComponentToSymfonyRector/Fixture/fixture.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerComponentToSymfonyRector/Source/Component.php delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerHelperToSymfonyRector/CakePHPControllerHelperToSymfonyRectorTest.php delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerHelperToSymfonyRector/Fixture/fixture.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerToSymfonyControllerRector/CakePHPControllerToSymfonyControllerRectorTest.php delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerToSymfonyControllerRector/Fixture/fixture.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPImplicitRouteToExplicitRouteAnnotationRector/CakePHPImplicitRouteToExplicitRouteAnnotationRectorTest.php delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPImplicitRouteToExplicitRouteAnnotationRector/Fixture/fixture.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPImplicitRouteToExplicitRouteAnnotationRector/Fixture/skip_private.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/CakePHPModelToDoctrineEntityRectorTest.php delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/Fixture/belongs_to.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/Fixture/has_many.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/Fixture/has_many_and_belongs_to_many.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/Fixture/has_one.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/Source/AppModel.php delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/CakePHPModelToDoctrineRepositoryRectorTest.php delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture/find_all.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture/find_count.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture/find_first.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture/find_list.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture/find_list_with_one_argument.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture/find_threaded.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Source/ExpectedFindAllRepository.php delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Source/ExpectedFindCountRepository.php delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Source/ExpectedFindFirstRepository.php delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Source/ExpectedFindListRepository.php delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Source/ExpectedFindListWithOneArgumentRepository.php delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Source/ExpectedFindThreadedRepository.php delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateHToTwigRector/CakePHPTemplateHToTwigRectorTest.php delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateHToTwigRector/Fixture/html_fixture.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateLinkToTwigRector/CakePHPTemplateToTwigRectorTest.php delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateLinkToTwigRector/Fixture/fixture.php.inc delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateTranslateToTwigRector/CakePHPTemplateTranslateToTwigRectorTest.php delete mode 100644 rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateTranslateToTwigRector/Fixture/fixture.php.inc diff --git a/composer.json b/composer.json index c57f9b120c50..9b6c60ff25da 100644 --- a/composer.json +++ b/composer.json @@ -58,7 +58,6 @@ "Rector\\AttributeAwarePhpDoc\\": "packages/attribute-aware-php-doc/src", "Rector\\Autodiscovery\\": "rules/autodiscovery/src", "Rector\\BetterPhpDocParser\\": "packages/better-php-doc-parser/src", - "Rector\\CakePHPToSymfony\\": "rules/cakephp-to-symfony/src", "Rector\\CakePHP\\": "rules/cakephp/src", "Rector\\Celebrity\\": "rules/celebrity/src", "Rector\\ChangesReporting\\": "packages/changes-reporting/src", @@ -143,7 +142,6 @@ "Rector\\Architecture\\Tests\\": "rules/architecture/tests", "Rector\\Autodiscovery\\Tests\\": "rules/autodiscovery/tests", "Rector\\BetterPhpDocParser\\Tests\\": "packages/better-php-doc-parser/tests", - "Rector\\CakePHPToSymfony\\Tests\\": "rules/cakephp-to-symfony/tests", "Rector\\CakePHP\\Tests\\": "rules/cakephp/tests", "Rector\\Celebrity\\Tests\\": "rules/celebrity/tests", "Rector\\CodeQuality\\Tests\\": "rules/code-quality/tests", @@ -220,8 +218,6 @@ "rules/autodiscovery/tests/Rector/FileSystem/MoveInterfacesToContractNamespaceDirectoryRector/Expected", "rules/autodiscovery/tests/Rector/FileSystem/MoveServicesBySuffixToDirectoryRector/Expected", "rules/cakephp/tests/Rector/StaticCall/AppUsesStaticCallToUseStatementRector/Source", - "rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerComponentToSymfonyRector/Source", - "rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/Source", "tests/Source", "tests/Rector/Psr4/MultipleClassFileToPsr4ClassesRector/Source", "tests/Rector/Namespace_/PseudoNamespaceToNamespaceRector/Source", diff --git a/config/set/cakephp-to-symfony/cakephp-24-to-symfony-51.yaml b/config/set/cakephp-to-symfony/cakephp-24-to-symfony-51.yaml deleted file mode 100644 index c85cb7d9a53b..000000000000 --- a/config/set/cakephp-to-symfony/cakephp-24-to-symfony-51.yaml +++ /dev/null @@ -1,20 +0,0 @@ -# from CakePHP 2.4.6 (April 2014) to Symfony 5.1 (May 2020) and Twig 3 -services: - # https://github.com/cakephp/cakephp/blob/2.4.6/lib/Cake/Controller/Controller.php - Rector\CakePHPToSymfony\Rector\Class_\CakePHPControllerToSymfonyControllerRector: null - Rector\CakePHPToSymfony\Rector\Class_\CakePHPControllerHelperToSymfonyRector: null - Rector\CakePHPToSymfony\Rector\Class_\CakePHPControllerComponentToSymfonyRector: null - Rector\CakePHPToSymfony\Rector\ClassMethod\CakePHPControllerRedirectToSymfonyRector: null - Rector\CakePHPToSymfony\Rector\ClassMethod\CakePHPControllerRenderToSymfonyRector: null - Rector\CakePHPToSymfony\Rector\ClassMethod\CakePHPControllerActionToSymfonyControllerActionRector: null - - # .tpl templates to twig - Rector\CakePHPToSymfony\Rector\Echo_\CakePHPTemplateLinkToTwigRector: null - Rector\CakePHPToSymfony\Rector\Echo_\CakePHPTemplateTranslateToTwigRector: null - Rector\CakePHPToSymfony\Rector\Echo_\CakePHPTemplateHToTwigRector: null - - # Model to Doctrine - Rector\CakePHPToSymfony\Rector\Class_\CakePHPModelToDoctrineEntityRector: null - Rector\CakePHPToSymfony\Rector\Class_\CakePHPModelToDoctrineRepositoryRector: null - Rector\CakePHPToSymfony\Rector\Class_\CakePHPImplicitRouteToExplicitRouteAnnotationRector: null - Rector\CakePHPToSymfony\Rector\Class_\CakePHPBeforeFilterToRequestEventSubscriberRector: null diff --git a/docs/rector_rules_overview.md b/docs/rector_rules_overview.md index a35670cbf100..3ad6f9636736 100644 --- a/docs/rector_rules_overview.md +++ b/docs/rector_rules_overview.md @@ -1,4 +1,4 @@ -# All 512 Rectors Overview +# All 499 Rectors Overview - [Projects](#projects) - [General](#general) @@ -9,7 +9,6 @@ - [Architecture](#architecture) - [Autodiscovery](#autodiscovery) - [CakePHP](#cakephp) -- [CakePHPToSymfony](#cakephptosymfony) - [Celebrity](#celebrity) - [CodeQuality](#codequality) - [CodingStyle](#codingstyle) @@ -380,326 +379,6 @@ services:
-## CakePHPToSymfony - -### `CakePHPBeforeFilterToRequestEventSubscriberRector` - -- class: [`Rector\CakePHPToSymfony\Rector\Class_\CakePHPBeforeFilterToRequestEventSubscriberRector`](/../master/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPBeforeFilterToRequestEventSubscriberRector.php) - -Migrate CakePHP beforeFilter() method from controller to Event Subscriber before request - -```diff - class SuperadminController extends \AppController - { -- public function beforeFilter() -- { -- // something -- } - } -``` - -
- -### `CakePHPControllerActionToSymfonyControllerActionRector` - -- class: [`Rector\CakePHPToSymfony\Rector\ClassMethod\CakePHPControllerActionToSymfonyControllerActionRector`](/../master/rules/cakephp-to-symfony/src/Rector/ClassMethod/CakePHPControllerActionToSymfonyControllerActionRector.php) -- [test fixtures](/../master/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerActionToSymfonyControllerActionRector/Fixture) - -Migrate CakePHP 2.4 Controller action to Symfony 5 - -```diff -+use Symfony\Component\HttpFoundation\Response; -+ - class HomepageController extends \AppController - { -- public function index() -+ public function index(): Response - { - $value = 5; - } - } -``` - -
- -### `CakePHPControllerComponentToSymfonyRector` - -- class: [`Rector\CakePHPToSymfony\Rector\Class_\CakePHPControllerComponentToSymfonyRector`](/../master/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPControllerComponentToSymfonyRector.php) -- [test fixtures](/../master/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerComponentToSymfonyRector/Fixture) - -Migrate CakePHP 2.4 Controller $components property to Symfony 5 - -```diff - class MessagesController extends \AppController - { -- public $components = ['Overview']; -+ private function __construct(OverviewComponent $overviewComponent) -+ { -+ $this->overviewComponent->filter(); -+ } - - public function someAction() - { -- $this->Overview->filter(); -+ $this->overviewComponent->filter(); - } - } - - class OverviewComponent extends \Component - { - public function filter() - { - } - } -``` - -
- -### `CakePHPControllerHelperToSymfonyRector` - -- class: [`Rector\CakePHPToSymfony\Rector\Class_\CakePHPControllerHelperToSymfonyRector`](/../master/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPControllerHelperToSymfonyRector.php) -- [test fixtures](/../master/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerHelperToSymfonyRector/Fixture) - -Migrate CakePHP 2.4 Controller $helpers and $components property to Symfony 5 - -```diff - class HomepageController extends AppController - { -- public $helpers = ['Flash']; -- - public function index() - { -- $this->Flash->success(__('Your post has been saved.')); -- $this->Flash->error(__('Unable to add your post.')); -+ $this->addFlash('success', __('Your post has been saved.')); -+ $this->addFlash('error', __('Unable to add your post.')); - } - } -``` - -
- -### `CakePHPControllerRedirectToSymfonyRector` - -- class: [`Rector\CakePHPToSymfony\Rector\ClassMethod\CakePHPControllerRedirectToSymfonyRector`](/../master/rules/cakephp-to-symfony/src/Rector/ClassMethod/CakePHPControllerRedirectToSymfonyRector.php) -- [test fixtures](/../master/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRedirectToSymfonyRector/Fixture) - -Migrate CakePHP 2.4 Controller redirect() to Symfony 5 - -```diff - class RedirectController extends \AppController - { - public function index() - { -- $this->redirect('boom'); -+ return $this->redirect('boom'); - } - } -``` - -
- -### `CakePHPControllerRenderToSymfonyRector` - -- class: [`Rector\CakePHPToSymfony\Rector\ClassMethod\CakePHPControllerRenderToSymfonyRector`](/../master/rules/cakephp-to-symfony/src/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector.php) -- [test fixtures](/../master/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector/Fixture) - -Migrate CakePHP 2.4 Controller render() to Symfony 5 - -```diff - class RedirectController extends \AppController - { - public function index() - { -- $this->render('custom_file'); -+ return $this->render('redirect/custom_file.twig'); - } - } -``` - -
- -### `CakePHPControllerToSymfonyControllerRector` - -- class: [`Rector\CakePHPToSymfony\Rector\Class_\CakePHPControllerToSymfonyControllerRector`](/../master/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPControllerToSymfonyControllerRector.php) -- [test fixtures](/../master/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerToSymfonyControllerRector/Fixture) - -Migrate CakePHP 2.4 Controller to Symfony 5 - -```diff --class HomepageController extends AppController -+use Symfony\Component\HttpFoundation\Response; -+use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -+ -+class HomepageController extends AbstractController - { -- public function index() -+ public function index(): Response - { - } - } -``` - -
- -### `CakePHPImplicitRouteToExplicitRouteAnnotationRector` - -- class: [`Rector\CakePHPToSymfony\Rector\Class_\CakePHPImplicitRouteToExplicitRouteAnnotationRector`](/../master/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPImplicitRouteToExplicitRouteAnnotationRector.php) -- [test fixtures](/../master/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPImplicitRouteToExplicitRouteAnnotationRector/Fixture) - -Migrate CakePHP implicit routes to Symfony @route annotations - -```diff --class PaymentsController extends AppController -+use Symfony\Component\Routing\Annotation\Route; -+ -+class AdminPaymentsController extends AppController - { -+ /** -+ * @Route(path="/payments/index", name="payments_index") -+ */ - public function index() - { - } - } -``` - -
- -### `CakePHPModelToDoctrineEntityRector` - -- class: [`Rector\CakePHPToSymfony\Rector\Class_\CakePHPModelToDoctrineEntityRector`](/../master/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPModelToDoctrineEntityRector.php) -- [test fixtures](/../master/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/Fixture) - -Migrate CakePHP Model active record to Doctrine\ORM Entity and EntityRepository - -```diff --class Activity extends \AppModel -+use Doctrine\Mapping\Annotation as ORM; -+ -+/** -+ * @ORM\Entity -+ */ -+class Activity - { -- public $belongsTo = [ -- 'ActivityType' => [ -- 'className' => 'ActivityType', -- 'foreignKey' => 'activity_type_id', -- 'dependent' => false, -- ], -- ]; -+ /** -+ * @ORM\ManyToOne(targetEntity="ActivityType") -+ * @ORM\JoinColumn(name="activity_type_id") -+ */ -+ private $activityType; - } -``` - -
- -### `CakePHPModelToDoctrineRepositoryRector` - -- class: [`Rector\CakePHPToSymfony\Rector\Class_\CakePHPModelToDoctrineRepositoryRector`](/../master/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPModelToDoctrineRepositoryRector.php) -- [test fixtures](/../master/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture) - -Migrate CakePHP Model active record to Doctrine\ORM\Repository with repository/DQL method calls - -```diff --class Activity extends \AppModel -+use Doctrine\ORM\EntityManagerInterface; -+ -+class Activity - { -+} -+ -+class ActivityRepository -+{ -+ /** -+ * @var EntityManagerInterface -+ */ -+ private $repository; -+ -+ public function __construct(EntityManagerInterface $entityManager) -+ { -+ $this->repository = $entityManager->getRepository(Activity::class); -+ } -+ - public function getAll() - { -- $result = $this->find('all'); -+ $result = $this->repository->findAll(); - - return $result; - } - - public function getOne() - { -- $result = $this->find('first', [ -- 'conditions' => [ -- 'DocumentVersionsSave.revision_number' => $versionId, -- 'DocumentVersionsSave.document_id' => $documentId, -- ], -- 'order' => [ -- 'created DESC', -- ], -- ]); -+ $result = $this->findOneBy([ -+ 'revision_number' => $versionId, -+ 'document_id' => $documentId, -+ ], 'created DESC'); - - return $result; - } - } -``` - -
- -### `CakePHPTemplateHToTwigRector` - -- class: [`Rector\CakePHPToSymfony\Rector\Echo_\CakePHPTemplateHToTwigRector`](/../master/rules/cakephp-to-symfony/src/Rector/Echo_/CakePHPTemplateHToTwigRector.php) -- [test fixtures](/../master/rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateHToTwigRector/Fixture) - -Migrate CakePHP 2.4 h() function calls to Twig - -```diff --

-+

{{ value|escape }}

-``` - -
- -### `CakePHPTemplateLinkToTwigRector` - -- class: [`Rector\CakePHPToSymfony\Rector\Echo_\CakePHPTemplateLinkToTwigRector`](/../master/rules/cakephp-to-symfony/src/Rector/Echo_/CakePHPTemplateLinkToTwigRector.php) - -Migrate CakePHP 2.4 template method calls to Twig - -```diff -
  • -- Html->link('List Rights', ['action' => 'index']); ?> -+ List Rights -
  • -``` - -
    - -### `CakePHPTemplateTranslateToTwigRector` - -- class: [`Rector\CakePHPToSymfony\Rector\Echo_\CakePHPTemplateTranslateToTwigRector`](/../master/rules/cakephp-to-symfony/src/Rector/Echo_/CakePHPTemplateTranslateToTwigRector.php) -- [test fixtures](/../master/rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateTranslateToTwigRector/Fixture) - -Migrate CakePHP 2.4 template method calls with translate to Twig - -```diff --

    -+

    {{ "Actions"|trans }}

    -``` - -
    - ## Celebrity ### `CommonNotEqualRector` diff --git a/rules/cakephp-to-symfony/config/config.yaml b/rules/cakephp-to-symfony/config/config.yaml deleted file mode 100644 index 8000f0a5e607..000000000000 --- a/rules/cakephp-to-symfony/config/config.yaml +++ /dev/null @@ -1,9 +0,0 @@ -services: - _defaults: - autowire: true - public: true - - Rector\CakePHPToSymfony\: - resource: '../src' - exclude: - - '../src/Rector/**/*Rector.php' diff --git a/rules/cakephp-to-symfony/src/Contract/NodeManipulator/RepositoryFindMethodCallManipulatorInterface.php b/rules/cakephp-to-symfony/src/Contract/NodeManipulator/RepositoryFindMethodCallManipulatorInterface.php deleted file mode 100644 index a4973789e8fe..000000000000 --- a/rules/cakephp-to-symfony/src/Contract/NodeManipulator/RepositoryFindMethodCallManipulatorInterface.php +++ /dev/null @@ -1,14 +0,0 @@ -builderFactory = $builderFactory; - $this->phpDocInfoFactory = $phpDocInfoFactory; - } - - public function createRepositoryProperty(): Property - { - $repositoryPropertyBuilder = $this->builderFactory->property('repository'); - $repositoryPropertyBuilder->makePrivate(); - - $repositoryProperty = $repositoryPropertyBuilder->getNode(); - - $phpDocInfo = $this->phpDocInfoFactory->createFromNode($repositoryProperty); - $phpDocInfo->changeVarType(new FullyQualifiedObjectType('Doctrine\ORM\EntityRepository')); - - return $repositoryProperty; - } - - public function createConstructorWithGetRepositoryAssign(string $entityClass): ClassMethod - { - $paramBuilder = $this->builderFactory->param('entityManager'); - $paramBuilder->setType(new FullyQualified(EntityManagerInterface::class)); - - $param = $paramBuilder->getNode(); - - $assign = $this->createRepositoryAssign($entityClass); - - return $this->builderFactory->method('__construct') - ->makePublic() - ->addParam($param) - ->addStmt($assign) - ->getNode(); - } - - /** - * Creates: - * $this->repository = $entityManager->getRepository(\EntityClass::class); - */ - private function createRepositoryAssign(string $entityClass): Assign - { - $repositoryPropertyFetch = new PropertyFetch(new Variable('this'), new Identifier('repository')); - - $entityClassReference = new ClassConstFetch(new FullyQualified($entityClass), 'class'); - - $getRepositoryMethodCall = new MethodCall(new Variable('entityManager'), 'getRepository', [ - new Arg($entityClassReference), - ]); - - return new Assign($repositoryPropertyFetch, $getRepositoryMethodCall); - } -} diff --git a/rules/cakephp-to-symfony/src/NodeFactory/EventSubscriberClassFactory.php b/rules/cakephp-to-symfony/src/NodeFactory/EventSubscriberClassFactory.php deleted file mode 100644 index 3b55bfe73524..000000000000 --- a/rules/cakephp-to-symfony/src/NodeFactory/EventSubscriberClassFactory.php +++ /dev/null @@ -1,104 +0,0 @@ -builderFactory = $builderFactory; - } - - /** - * @return Namespace_|Class_ - */ - public function createEventSubscriberClass(Class_ $class, ClassMethod $onBeforeFilterClassMethod): Node - { - $eventSubscriberClassName = $this->createEventSubscriberClassName($class); - - $classBuilder = $this->builderFactory->class($eventSubscriberClassName); - $classBuilder->implement(new FullyQualified('Symfony\Component\EventDispatcher\EventSubscriberInterface')); - $classBuilder->makeFinal(); - - $classBuilder->addStmt($this->createGetSubscribedEventsClassMethod()); - $classBuilder->addStmt($this->createOnKernelRequestClassMethod($onBeforeFilterClassMethod)); - - $eventSubscriberClass = $classBuilder->getNode(); - - /** @var string|null $namespaceName */ - $namespaceName = $class->getAttribute(AttributeKey::NAMESPACE_NAME); - if ($namespaceName === null) { - return $eventSubscriberClass; - } - - $namespace = new Namespace_(new Name($namespaceName)); - $namespace->stmts[] = $eventSubscriberClass; - - return $namespace; - } - - public function resolveEventSubscriberFilePath(Class_ $class): string - { - /** @var SmartFileInfo $fileInfo */ - $fileInfo = $class->getAttribute(AttributeKey::FILE_INFO); - $eventSubscriberClassName = $this->createEventSubscriberClassName($class); - return dirname($fileInfo->getRealPath()) . DIRECTORY_SEPARATOR . $eventSubscriberClassName . '.php'; - } - - private function createEventSubscriberClassName(Class_ $class): string - { - $className = $class->getAttribute(AttributeKey::CLASS_SHORT_NAME); - - return $className . 'EventSubscriber'; - } - - private function createGetSubscribedEventsClassMethod(): ClassMethod - { - $classMethodBuilder = $this->builderFactory->method('getSubscribedEvents'); - $classMethodBuilder->makePublic(); - $classMethodBuilder->makeStatic(); - - $eventConstant = new ClassConstFetch(new FullyQualified( - 'Symfony\Component\HttpKernel\KernelEvents' - ), 'REQUEST'); - $arrayItem = new ArrayItem(new String_('onKernelRequest'), $eventConstant); - $eventsToMethodsArray = new Array_([$arrayItem]); - - $return = new Return_($eventsToMethodsArray); - $classMethodBuilder->addStmt($return); - $classMethodBuilder->setReturnType('array'); - - return $classMethodBuilder->getNode(); - } - - private function createOnKernelRequestClassMethod(ClassMethod $onBeforeFilterClassMethod): ClassMethod - { - $classMethodBuilder = $this->builderFactory->method('onKernelRequest'); - $classMethodBuilder->addStmts((array) $onBeforeFilterClassMethod->stmts); - $classMethodBuilder->makePublic(); - - return $classMethodBuilder->getNode(); - } -} diff --git a/rules/cakephp-to-symfony/src/NodeFactory/RelationPropertyFactory.php b/rules/cakephp-to-symfony/src/NodeFactory/RelationPropertyFactory.php deleted file mode 100644 index a5880e9b5977..000000000000 --- a/rules/cakephp-to-symfony/src/NodeFactory/RelationPropertyFactory.php +++ /dev/null @@ -1,175 +0,0 @@ -valueResolver = $valueResolver; - $this->phpDocInfoFactory = $phpDocInfoFactory; - } - - /** - * @return Property[] - */ - public function createManyToOneProperties(Property $belongToProperty): array - { - $belongsToValue = $this->getPropertyDefaultValue($belongToProperty); - - $properties = []; - foreach ($belongsToValue as $propertyName => $manyToOneConfiguration) { - $property = $this->createPrivateProperty($propertyName); - - $className = $manyToOneConfiguration['className']; - - // add @ORM\ManyToOne - $manyToOneTagValueNode = new ManyToOneTagValueNode([ - 'targetEntity' => $className, - ], null, $className); - - $phpDocInfo = $this->phpDocInfoFactory->createFromNode($property); - $phpDocInfo->addTagValueNodeWithShortName($manyToOneTagValueNode); - - // add @ORM\JoinColumn - $joinColumnTagValueNode = new JoinColumnTagValueNode([ - 'name' => $manyToOneConfiguration['foreignKey'], - ]); - - $phpDocInfo->addTagValueNodeWithShortName($joinColumnTagValueNode); - - $properties[] = $property; - } - - return $properties; - } - - /** - * @return Property[] - */ - public function createOneToOneProperties(Property $hasOneProperty): array - { - $propertyDefaultValue = $this->getPropertyDefaultValue($hasOneProperty); - - $properties = []; - foreach ($propertyDefaultValue as $propertyName => $relationConfiguration) { - $property = $this->createPrivateProperty($propertyName); - - // add @ORM\OneToOne - $oneToOneTagValueNode = new OneToOneTagValueNode([ - 'targetEntity' => $relationConfiguration['className'], - ]); - - $phpDocInfo = $this->phpDocInfoFactory->createFromNode($property); - $phpDocInfo->addTagValueNodeWithShortName($oneToOneTagValueNode); - - $properties[] = $property; - } - - return $properties; - } - - /** - * @return Property[] - */ - public function createManyToManyProperties(Property $hasAndBelongsToManyProperty): array - { - $hasAndBelongsToValue = $this->getPropertyDefaultValue($hasAndBelongsToManyProperty); - - $properties = []; - foreach ($hasAndBelongsToValue as $propertyName => $manyToOneConfiguration) { - $property = $this->createPrivateProperty($propertyName); - - // add @ORM\ManyToOne - $manyToOneTagValueNode = new ManyToManyTagValueNode([ - 'targetEntity' => $manyToOneConfiguration['className'], - ]); - - $phpDocInfo = $this->phpDocInfoFactory->createFromNode($property); - $phpDocInfo->addTagValueNodeWithShortName($manyToOneTagValueNode); - - $properties[] = $property; - } - - return $properties; - } - - /** - * @return Property[] - */ - public function createOneToManyProperties(Property $hasManyProperty): array - { - $propertyDefaultValue = $this->getPropertyDefaultValue($hasManyProperty); - - $properties = []; - foreach ($propertyDefaultValue as $propertyName => $relationConfiguration) { - $property = $this->createPrivateProperty($propertyName); - - $className = $relationConfiguration['className']; - - // add @ORM\OneToMany - $manyToOneTagValueNode = new OneToManyTagValueNode(['targetEntity' => $className]); - - /** @var PhpDocInfo $phpDocInfo */ - $phpDocInfo = $this->phpDocInfoFactory->createFromNode($property); - $phpDocInfo->addTagValueNodeWithShortName($manyToOneTagValueNode); - - $properties[] = $property; - } - - return $properties; - } - - private function getPropertyDefaultValue(Property $property): array - { - if (count((array) $property->props) !== 1) { - throw new ShouldNotHappenException(); - } - - $onlyPropertyDefault = $property->props[0]->default; - if ($onlyPropertyDefault === null) { - throw new ShouldNotHappenException(); - } - - $value = $this->valueResolver->getValue($onlyPropertyDefault); - if (! is_array($value)) { - throw new ShouldNotHappenException(); - } - - return $value; - } - - private function createPrivateProperty(string $propertyName): Property - { - $propertyName = lcfirst($propertyName); - - $propertyBuilder = new PropertyBuilder($propertyName); - $propertyBuilder->makePrivate(); - - return $propertyBuilder->getNode(); - } -} diff --git a/rules/cakephp-to-symfony/src/NodeManipulator/DoctrineRepositoryClassMethodManipulator.php b/rules/cakephp-to-symfony/src/NodeManipulator/DoctrineRepositoryClassMethodManipulator.php deleted file mode 100644 index 31362823e27a..000000000000 --- a/rules/cakephp-to-symfony/src/NodeManipulator/DoctrineRepositoryClassMethodManipulator.php +++ /dev/null @@ -1,87 +0,0 @@ -callableNodeTraverser = $callableNodeTraverser; - $this->nodeNameResolver = $nodeNameResolver; - $this->valueResolver = $valueResolver; - $this->repositoryFindMethodCallManipulators = $repositoryFindMethodCallManipulators; - } - - public function createFromCakePHPClassMethod(ClassMethod $classMethod, string $entityClass): ClassMethod - { - $this->callableNodeTraverser->traverseNodesWithCallable( - (array) $classMethod->getStmts(), - function (Node $node) use ($entityClass) { - if (! $node instanceof MethodCall) { - return null; - } - - if (! $this->nodeNameResolver->isName($node->name, 'find')) { - return null; - } - - return $this->refactorClassMethodByKind($node, $entityClass); - } - ); - - return $classMethod; - } - - private function refactorClassMethodByKind(MethodCall $methodCall, string $entityClass): Node - { - $findKind = $this->valueResolver->getValue($methodCall->args[0]->value); - - foreach ($this->repositoryFindMethodCallManipulators as $repositoryFindMethodCallManipulator) { - if ($findKind !== $repositoryFindMethodCallManipulator->getKeyName()) { - continue; - } - - return $repositoryFindMethodCallManipulator->processMethodCall($methodCall, $entityClass); - } - - throw new NotImplementedException($findKind); - } -} diff --git a/rules/cakephp-to-symfony/src/NodeManipulator/RepositoryFindClassMethodManipulator/AbstractRepositoryFindMethodCallManipulator.php b/rules/cakephp-to-symfony/src/NodeManipulator/RepositoryFindClassMethodManipulator/AbstractRepositoryFindMethodCallManipulator.php deleted file mode 100644 index a38138d093c7..000000000000 --- a/rules/cakephp-to-symfony/src/NodeManipulator/RepositoryFindClassMethodManipulator/AbstractRepositoryFindMethodCallManipulator.php +++ /dev/null @@ -1,101 +0,0 @@ -valueResolver = $valueResolver; - } - - protected function refactorToRepositoryMethod(MethodCall $methodCall, string $methodName): void - { - $methodCall->var = new PropertyFetch(new Variable('this'), 'repository'); - $methodCall->name = new Identifier($methodName); - } - - protected function findConfigurationByKey( - MethodCall $methodCall, - string $configurationKey, - string $entityClass - ): ?Array_ { - if (! isset($methodCall->args[1])) { - return null; - } - - $possibleArray = $methodCall->args[1]->value; - if (! $possibleArray instanceof Array_) { - return null; - } - - $conditionsArrayItem = $this->getItemByKey($possibleArray, $configurationKey); - if ($conditionsArrayItem === null) { - return null; - } - - $conditionsArrayItemArray = $conditionsArrayItem->value; - if (! $conditionsArrayItemArray instanceof Array_) { - throw new ShouldNotHappenException(); - } - - $this->removeEntityPrefixFromConditionKeys($conditionsArrayItemArray, $entityClass); - - return $conditionsArrayItemArray; - } - - private function getItemByKey(Array_ $array, string $key): ?ArrayItem - { - foreach ($array->items as $arrayItem) { - if ($arrayItem->key === null) { - continue; - } - - if (! $this->valueResolver->isValue($arrayItem->key, $key)) { - continue; - } - - return $arrayItem; - } - - return null; - } - - private function removeEntityPrefixFromConditionKeys(Array_ $conditionArray, string $entityClass): void - { - // clear keys from current class - foreach ($conditionArray->items as $conditionArrayItem) { - if (! $conditionArrayItem->key instanceof String_) { - continue; - } - - $this->clearStringFromEntityPrefix($conditionArrayItem->key, $entityClass); - } - } - - private function clearStringFromEntityPrefix(String_ $string, string $entityClass): void - { - $string->value = Strings::replace($string->value, '#^' . $entityClass . '\.#'); - } -} diff --git a/rules/cakephp-to-symfony/src/NodeManipulator/RepositoryFindClassMethodManipulator/FindAllRepositoryFindMethodCallManipulator.php b/rules/cakephp-to-symfony/src/NodeManipulator/RepositoryFindClassMethodManipulator/FindAllRepositoryFindMethodCallManipulator.php deleted file mode 100644 index 9dd6badf8adc..000000000000 --- a/rules/cakephp-to-symfony/src/NodeManipulator/RepositoryFindClassMethodManipulator/FindAllRepositoryFindMethodCallManipulator.php +++ /dev/null @@ -1,25 +0,0 @@ -refactorToRepositoryMethod($methodCall, 'findAll'); - - $methodCall->args = []; - - return $methodCall; - } -} diff --git a/rules/cakephp-to-symfony/src/NodeManipulator/RepositoryFindClassMethodManipulator/FindCountRepositoryFindMethodCallManipulator.php b/rules/cakephp-to-symfony/src/NodeManipulator/RepositoryFindClassMethodManipulator/FindCountRepositoryFindMethodCallManipulator.php deleted file mode 100644 index a83384242859..000000000000 --- a/rules/cakephp-to-symfony/src/NodeManipulator/RepositoryFindClassMethodManipulator/FindCountRepositoryFindMethodCallManipulator.php +++ /dev/null @@ -1,32 +0,0 @@ -refactorToRepositoryMethod($methodCall, 'count'); - - $conditionsArray = $this->findConfigurationByKey($methodCall, 'conditions', $entityClass); - - if ($conditionsArray === null) { - return $methodCall; - } - - $methodCall->args = [new Arg($conditionsArray)]; - - return $methodCall; - } -} diff --git a/rules/cakephp-to-symfony/src/NodeManipulator/RepositoryFindClassMethodManipulator/FindFirstRepositoryFindMethodCallManipulator.php b/rules/cakephp-to-symfony/src/NodeManipulator/RepositoryFindClassMethodManipulator/FindFirstRepositoryFindMethodCallManipulator.php deleted file mode 100644 index 299e78ca05b1..000000000000 --- a/rules/cakephp-to-symfony/src/NodeManipulator/RepositoryFindClassMethodManipulator/FindFirstRepositoryFindMethodCallManipulator.php +++ /dev/null @@ -1,69 +0,0 @@ -refactorToRepositoryMethod($methodCall, 'findOneBy'); - - unset($methodCall->args[0]); - if (! isset($methodCall->args[1])) { - return $methodCall; - } - - $firstArgument = $methodCall->args[1]->value; - if (! $firstArgument instanceof Array_) { - return $methodCall; - } - - $methodCall->args = $this->createFindOneByArgs($entityClass, $methodCall); - - return $methodCall; - } - - /** - * @return Arg[] - */ - private function createFindOneByArgs(string $entityClass, MethodCall $methodCall): array - { - $args = []; - - $conditionsArray = $this->findConfigurationByKey($methodCall, 'conditions', $entityClass); - if ($conditionsArray !== null) { - $args[] = new Arg($conditionsArray); - } - - $orderArray = $this->findConfigurationByKey($methodCall, 'order', $entityClass); - if ($orderArray !== null) { - if (count($args) === 0) { - $args[] = new Arg($this->createNull()); - } - - assert(isset($orderArray->items[0])); - $args[] = new Arg($orderArray->items[0]); - } - - return $args; - } - - private function createNull(): ConstFetch - { - return new ConstFetch(new Name('null')); - } -} diff --git a/rules/cakephp-to-symfony/src/NodeManipulator/RepositoryFindClassMethodManipulator/FindListRepositoryFindMethodCallManipulator.php b/rules/cakephp-to-symfony/src/NodeManipulator/RepositoryFindClassMethodManipulator/FindListRepositoryFindMethodCallManipulator.php deleted file mode 100644 index c9da34f98303..000000000000 --- a/rules/cakephp-to-symfony/src/NodeManipulator/RepositoryFindClassMethodManipulator/FindListRepositoryFindMethodCallManipulator.php +++ /dev/null @@ -1,45 +0,0 @@ -args[] = new Arg($hydrateArrayClassConstFetch); - - return $getResultMethodCall; - } -} diff --git a/rules/cakephp-to-symfony/src/NodeManipulator/RepositoryFindClassMethodManipulator/FindThreadedRepositoryFindMethodCallManipulator.php b/rules/cakephp-to-symfony/src/NodeManipulator/RepositoryFindClassMethodManipulator/FindThreadedRepositoryFindMethodCallManipulator.php deleted file mode 100644 index 2ea1e0f5f54b..000000000000 --- a/rules/cakephp-to-symfony/src/NodeManipulator/RepositoryFindClassMethodManipulator/FindThreadedRepositoryFindMethodCallManipulator.php +++ /dev/null @@ -1,33 +0,0 @@ -refactorToRepositoryMethod($methodCall, 'findBy'); - - unset($methodCall->args[0]); - - $conditionsArray = $this->findConfigurationByKey($methodCall, 'conditions', $entityClass); - if ($conditionsArray === null) { - return $methodCall; - } - - $methodCall->args = [new Arg($conditionsArray)]; - - return $methodCall; - } -} diff --git a/rules/cakephp-to-symfony/src/Rector/AbstractCakePHPRector.php b/rules/cakephp-to-symfony/src/Rector/AbstractCakePHPRector.php deleted file mode 100644 index f1943fba35c5..000000000000 --- a/rules/cakephp-to-symfony/src/Rector/AbstractCakePHPRector.php +++ /dev/null @@ -1,22 +0,0 @@ -isObjectType($node, 'AppController')) { - return true; - } - - $class = $node->getAttribute(AttributeKey::CLASS_NODE); - return $class !== null; - } -} diff --git a/rules/cakephp-to-symfony/src/Rector/ClassMethod/CakePHPControllerActionToSymfonyControllerActionRector.php b/rules/cakephp-to-symfony/src/Rector/ClassMethod/CakePHPControllerActionToSymfonyControllerActionRector.php deleted file mode 100644 index df67ec500f2f..000000000000 --- a/rules/cakephp-to-symfony/src/Rector/ClassMethod/CakePHPControllerActionToSymfonyControllerActionRector.php +++ /dev/null @@ -1,80 +0,0 @@ -view - * - * @see \Rector\CakePHPToSymfony\Tests\Rector\ClassMethod\CakePHPControllerActionToSymfonyControllerActionRector\CakePHPControllerActionToSymfonyControllerActionRectorTest - */ -final class CakePHPControllerActionToSymfonyControllerActionRector extends AbstractCakePHPRector -{ - public function getDefinition(): RectorDefinition - { - return new RectorDefinition('Migrate CakePHP 2.4 Controller action to Symfony 5', [ - new CodeSample( - <<<'PHP' -class HomepageController extends \AppController -{ - public function index() - { - $value = 5; - } -} -PHP -, - <<<'PHP' -use Symfony\Component\HttpFoundation\Response; - -class HomepageController extends \AppController -{ - public function index(): Response - { - $value = 5; - } -} -PHP - - ), - ]); - } - - /** - * @return string[] - */ - public function getNodeTypes(): array - { - return [ClassMethod::class]; - } - - /** - * @param ClassMethod $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->isInCakePHPController($node)) { - return null; - } - - if (! $node->isPublic()) { - return null; - } - - $node->returnType = new FullyQualified('Symfony\Component\HttpFoundation\Response'); - - return $node; - } -} diff --git a/rules/cakephp-to-symfony/src/Rector/ClassMethod/CakePHPControllerRedirectToSymfonyRector.php b/rules/cakephp-to-symfony/src/Rector/ClassMethod/CakePHPControllerRedirectToSymfonyRector.php deleted file mode 100644 index 2e4d3e451898..000000000000 --- a/rules/cakephp-to-symfony/src/Rector/ClassMethod/CakePHPControllerRedirectToSymfonyRector.php +++ /dev/null @@ -1,151 +0,0 @@ -redirect('boom'); - } -} -PHP -, - <<<'PHP' -class RedirectController extends \AppController -{ - public function index() - { - return $this->redirect('boom'); - } -} -PHP - - ), - ]); - } - - /** - * @return string[] - */ - public function getNodeTypes(): array - { - return [ClassMethod::class]; - } - - /** - * @param ClassMethod $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->isInCakePHPController($node)) { - return null; - } - - $this->traverseNodesWithCallable($node, function (Node $node) { - if ($node instanceof Return_) { - $returnedExpr = $node->expr; - if ($returnedExpr === null) { - return null; - } - - return $this->refactorRedirectMethodCall($returnedExpr); - } - - if ($node instanceof Expression) { - return $this->refactorRedirectMethodCall($node); - } - - return null; - }); - - return $node; - } - - /** - * @param Expr|Expression $expr - */ - private function refactorRedirectMethodCall($expr): ?Return_ - { - if ($expr instanceof Expression) { - $expr = $expr->expr; - } - - if (! $expr instanceof MethodCall) { - return null; - } - - if (! $this->isName($expr->var, 'this')) { - return null; - } - - if (! $this->isName($expr->name, 'redirect')) { - return null; - } - - $this->refactorRedirectArgs($expr); - - $parentNode = $expr->getAttribute(AttributeKey::PARENT_NODE); - if ($parentNode instanceof Return_) { - return null; - } - - // add "return" - return new Return_($expr); - } - - private function refactorRedirectArgs(MethodCall $methodCall): void - { - $argumentValue = $methodCall->args[0]->value; - if ($argumentValue instanceof String_) { - return; - } - - // not sure what to do - if (! $argumentValue instanceof Array_) { - return; - } - - $argumentValue = $this->getValue($argumentValue); - - if (! isset($argumentValue['controller']) || ! isset($argumentValue['action'])) { - return; - } - - $composedRouteName = $argumentValue['controller'] . '_' . $argumentValue['action']; - $composedRouteName = StaticRectorStrings::camelCaseToUnderscore($composedRouteName); - - $methodCall->args[0]->value = new String_($composedRouteName); - $methodCall->name = new Identifier('redirectToRoute'); - } -} diff --git a/rules/cakephp-to-symfony/src/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector.php b/rules/cakephp-to-symfony/src/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector.php deleted file mode 100644 index 83f88a0f0993..000000000000 --- a/rules/cakephp-to-symfony/src/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector.php +++ /dev/null @@ -1,215 +0,0 @@ -templatePathResolver = $templatePathResolver; - $this->compactConverter = $compactConverter; - $this->templateMethodCallManipulator = $templateMethodCallManipulator; - } - - public function getDefinition(): RectorDefinition - { - return new RectorDefinition('Migrate CakePHP 2.4 Controller render() to Symfony 5', [ - new CodeSample( - <<<'PHP' -class RedirectController extends \AppController -{ - public function index() - { - $this->render('custom_file'); - } -} -PHP -, - <<<'PHP' -class RedirectController extends \AppController -{ - public function index() - { - return $this->render('redirect/custom_file.twig'); - } -} -PHP - - ), - ]); - } - - /** - * @return string[] - */ - public function getNodeTypes(): array - { - return [ClassMethod::class]; - } - - /** - * @param ClassMethod $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->isInCakePHPController($node)) { - return null; - } - - if ($this->hasRenderMethodCall($node)) { - $this->templateMethodCallManipulator->refactorExistingRenderMethodCall($node); - return null; - } - - $this->completeImplicitRenderMethodCall($node); - - return $node; - } - - private function hasRenderMethodCall(ClassMethod $classMethod): bool - { - return (bool) $this->betterNodeFinder->findFirst($classMethod, function (Node $node) { - return $this->isThisRenderMethodCall($node); - }); - } - - private function completeImplicitRenderMethodCall(ClassMethod $classMethod): void - { - $methodCall = $this->createThisRenderMethodCall($classMethod); - $return = new Return_($methodCall); - - $classMethod->stmts[] = $return; - } - - private function isThisRenderMethodCall(Node $node): bool - { - if (! $node instanceof MethodCall) { - return false; - } - - if (! $this->isName($node->var, 'this')) { - return false; - } - - return $this->isName($node->name, 'render'); - } - - /** - * Creates "$this->render('...', [...])"; - */ - private function createThisRenderMethodCall(ClassMethod $classMethod): MethodCall - { - $thisVariable = new Variable('this'); - $thisRenderMethodCall = new MethodCall($thisVariable, 'render'); - - $templateName = $this->templatePathResolver->resolveForClassMethod($classMethod); - $thisRenderMethodCall->args[] = new Arg(new String_($templateName)); - - $setValues = $this->collectAndRemoveSetMethodCallArgs((array) $classMethod->stmts); - - if ($setValues !== []) { - $parametersArray = $this->createArrayFromSetValues($setValues); - $thisRenderMethodCall->args[] = new Arg($parametersArray); - } - - return $thisRenderMethodCall; - } - - /** - * @return Arg[][] - */ - private function collectAndRemoveSetMethodCallArgs(array $stmts): array - { - $setMethodCallArgs = []; - - $this->traverseNodesWithCallable($stmts, function (Node $node) use (&$setMethodCallArgs) { - if (! $node instanceof MethodCall) { - return null; - } - - if (! $this->isName($node->name, 'set')) { - return null; - } - - $setMethodCallArgs[] = $node->args; - $this->removeNode($node); - - return null; - }); - - return $setMethodCallArgs; - } - - /** - * @param Arg[][] $setValues - */ - private function createArrayFromSetValues(array $setValues): Array_ - { - $arrayItems = []; - - foreach ($setValues as $setValue) { - if (count($setValue) > 1) { - $arrayItems[] = new ArrayItem($setValue[1]->value, $setValue[0]->value); - } elseif ($this->isCompactFuncCall($setValue[0]->value)) { - /** @var FuncCall $compactFuncCall */ - $compactFuncCall = $setValue[0]->value; - - return $this->compactConverter->convertToArray($compactFuncCall); - } - } - - return new Array_($arrayItems); - } - - private function isCompactFuncCall(Node $node): bool - { - if (! $node instanceof FuncCall) { - return false; - } - - return $this->isName($node, 'compact'); - } -} diff --git a/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPBeforeFilterToRequestEventSubscriberRector.php b/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPBeforeFilterToRequestEventSubscriberRector.php deleted file mode 100644 index 9bdb6648455a..000000000000 --- a/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPBeforeFilterToRequestEventSubscriberRector.php +++ /dev/null @@ -1,94 +0,0 @@ -eventSubscriberClassFactory = $eventSubscriberClassFactory; - } - - public function getDefinition(): RectorDefinition - { - return new RectorDefinition( - 'Migrate CakePHP beforeFilter() method from controller to Event Subscriber before request', - [ - new CodeSample( - <<<'PHP' -class SuperadminController extends \AppController -{ - public function beforeFilter() - { - // something - } -} -PHP -, - <<<'PHP' -class SuperadminController extends \AppController -{ -} -PHP - - ), - ] - ); - } - - /** - * @return string[] - */ - public function getNodeTypes(): array - { - return [Class_::class]; - } - - /** - * @param Class_ $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->isInCakePHPController($node)) { - return null; - } - - $beforeFilterClassMethod = $node->getMethod('beforeFilter'); - if ($beforeFilterClassMethod === null) { - return null; - } - - $this->removeNode($beforeFilterClassMethod); - - // create event subscriber with name... - $eventSubscriberClass = $this->eventSubscriberClassFactory->createEventSubscriberClass( - $node, - $beforeFilterClassMethod - ); - $eventSubscriberFilePath = $this->eventSubscriberClassFactory->resolveEventSubscriberFilePath($node); - - $this->printToFile($eventSubscriberClass, $eventSubscriberFilePath); - - return null; - } -} diff --git a/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPControllerComponentToSymfonyRector.php b/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPControllerComponentToSymfonyRector.php deleted file mode 100644 index 4e9c95ea1c46..000000000000 --- a/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPControllerComponentToSymfonyRector.php +++ /dev/null @@ -1,186 +0,0 @@ -classManipulator = $classManipulator; - } - - public function getDefinition(): RectorDefinition - { - return new RectorDefinition('Migrate CakePHP 2.4 Controller $components property to Symfony 5', [ - new CodeSample( - <<<'PHP' -class MessagesController extends \AppController -{ - public $components = ['Overview']; - - public function someAction() - { - $this->Overview->filter(); - } -} - -class OverviewComponent extends \Component -{ - public function filter() - { - } -} -PHP -, - <<<'PHP' -class MessagesController extends \AppController -{ - private function __construct(OverviewComponent $overviewComponent) - { - $this->overviewComponent->filter(); - } - - public function someAction() - { - $this->overviewComponent->filter(); - } -} - -class OverviewComponent extends \Component -{ - public function filter() - { - } -} -PHP - - ), - ]); - } - - /** - * @return string[] - */ - public function getNodeTypes(): array - { - return [Class_::class]; - } - - /** - * @param Class_ $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->isInCakePHPController($node)) { - return null; - } - - $componentsProperty = $node->getProperty('components'); - if ($componentsProperty === null) { - return null; - } - - $defaultValue = $componentsProperty->props[0]->default; - if ($defaultValue === null) { - return null; - } - - $componentNames = $this->getValue($defaultValue); - if (! is_array($componentNames)) { - throw new ShouldNotHappenException(); - } - - $this->removeNode($componentsProperty); - - $componentClasses = $this->matchComponentClass($componentNames); - - $oldProperyNameToNewPropertyName = []; - - foreach ($componentClasses as $componentName => $componentClass) { - $componentClassShortName = $this->getShortName($componentClass); - $propertyShortName = lcfirst($componentClassShortName); - $this->addPropertyToClass($node, new ObjectType($componentClass), $propertyShortName); - - $oldProperyNameToNewPropertyName[$componentName] = $propertyShortName; - } - - $this->classManipulator->renamePropertyFetches($node, $oldProperyNameToNewPropertyName); - - return $node; - } - - /** - * @param string[] $componentNames - * @return string[] - */ - private function matchComponentClass(array $componentNames): array - { - $componentsClasses = $this->getComponentClasses(); - - $matchedComponentClasses = []; - - foreach ($componentNames as $componentName) { - foreach ($componentsClasses as $componentClass) { - $shortComponentClass = $this->getShortName($componentClass); - if (! Strings::startsWith($shortComponentClass, $componentName)) { - continue; - } - - $matchedComponentClasses[$componentName] = $componentClass; - } - } - - return $matchedComponentClasses; - } - - /** - * @return string[] - */ - private function getComponentClasses(): array - { - if ($this->componentsClasses !== []) { - return $this->componentsClasses; - } - - foreach (get_declared_classes() as $declaredClass) { - if ($declaredClass === 'Component') { - continue; - } - - if (! is_a($declaredClass, 'Component', true)) { - continue; - } - - $this->componentsClasses[] = $declaredClass; - } - - return $this->componentsClasses; - } -} diff --git a/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPControllerHelperToSymfonyRector.php b/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPControllerHelperToSymfonyRector.php deleted file mode 100644 index 417a945ac42a..000000000000 --- a/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPControllerHelperToSymfonyRector.php +++ /dev/null @@ -1,118 +0,0 @@ -Flash->success(__('Your post has been saved.')); - $this->Flash->error(__('Unable to add your post.')); - } -} -PHP -, - <<<'PHP' -class HomepageController extends AppController -{ - public function index() - { - $this->addFlash('success', __('Your post has been saved.')); - $this->addFlash('error', __('Unable to add your post.')); - } -} -PHP - - ), - ]); - } - - /** - * @return string[] - */ - public function getNodeTypes(): array - { - return [Class_::class]; - } - - /** - * @param Class_ $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->isInCakePHPController($node)) { - return null; - } - - $helpersProperty = $node->getProperty('helpers'); - if ($helpersProperty === null) { - return null; - } - - // remove $helpers completely - $this->removeNode($helpersProperty); - - // replace $this->Flash->.. → $this->addFlash(...) - foreach ($node->getMethods() as $classMethod) { - $this->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) { - if (! $this->isThisFlashMethodCall($node)) { - return null; - } - - /** @var MethodCall $node */ - $message = $node->args[0]->value; - - $kind = $this->getName($node->name); - if ($kind === null) { - throw new ShouldNotHappenException(); - } - - $thisVariable = new Variable('this'); - - $args = [new Arg(new String_($kind)), new Arg($message)]; - - return new MethodCall($thisVariable, 'addFlash', $args); - }); - } - - return $node; - } - - private function isThisFlashMethodCall(Node $node): bool - { - if (! $node instanceof MethodCall) { - return false; - } - - return $this->isLocalPropertyFetchName($node->var, 'Flash'); - } -} diff --git a/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPControllerToSymfonyControllerRector.php b/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPControllerToSymfonyControllerRector.php deleted file mode 100644 index ffdb25be4f8a..000000000000 --- a/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPControllerToSymfonyControllerRector.php +++ /dev/null @@ -1,73 +0,0 @@ -isInCakePHPController($node)) { - return null; - } - - $node->extends = new FullyQualified('Symfony\Bundle\FrameworkBundle\Controller\AbstractController'); - - return $node; - } -} diff --git a/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPImplicitRouteToExplicitRouteAnnotationRector.php b/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPImplicitRouteToExplicitRouteAnnotationRector.php deleted file mode 100644 index 9fc3285a6da7..000000000000 --- a/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPImplicitRouteToExplicitRouteAnnotationRector.php +++ /dev/null @@ -1,116 +0,0 @@ -implicitToExplicitRoutingAnnotationDecorator = $implicitToExplicitRoutingAnnotationDecorator; - } - - public function getDefinition(): RectorDefinition - { - return new RectorDefinition('Migrate CakePHP implicit routes to Symfony @route annotations', [ - new CodeSample( - <<<'PHP' -class PaymentsController extends AppController -{ - public function index() - { - } -} -PHP -, - <<<'PHP' -use Symfony\Component\Routing\Annotation\Route; - -class AdminPaymentsController extends AppController -{ - /** - * @Route(path="/payments/index", name="payments_index") - */ - public function index() - { - } -} -PHP - - ), - ]); - } - - /** - * @return string[] - */ - public function getNodeTypes(): array - { - return [Class_::class]; - } - - /** - * @param Class_ $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->isInCakePHPController($node)) { - return null; - } - - foreach ($node->getMethods() as $classMethod) { - if (! $classMethod->isPublic()) { - continue; - } - - /** @var string $shortClassName */ - $shortClassName = $node->getAttribute(AttributeKey::CLASS_SHORT_NAME); - - $methodName = $this->getName($classMethod); - - $combined = StaticRectorStrings::removeSuffixes($shortClassName, ['Controller']) . '/' . $methodName; - $path = '/' . StaticRectorStrings::camelCaseToSlashes($combined); - $name = StaticRectorStrings::camelCaseToUnderscore($combined); - - $symfonyRoutePhpDocTagValueNode = $this->createSymfonyRoutePhpDocTagValueNode($path, $name); - - $this->implicitToExplicitRoutingAnnotationDecorator->decorateClassMethodWithRouteAnnotation( - $classMethod, - $symfonyRoutePhpDocTagValueNode - ); - } - - return $node; - } - - private function createSymfonyRoutePhpDocTagValueNode(string $path, string $name): SymfonyRouteTagValueNode - { - return new SymfonyRouteTagValueNode([ - 'path' => $path, - 'name' => $name, - ]); - } -} diff --git a/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPModelToDoctrineEntityRector.php b/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPModelToDoctrineEntityRector.php deleted file mode 100644 index 1d7b6af91163..000000000000 --- a/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPModelToDoctrineEntityRector.php +++ /dev/null @@ -1,152 +0,0 @@ - one to one - * hasMany => one to many - * belongsTo => many to one - * hasAndBelongsToMany => many to many - * - * @see https://book.cakephp.org/2/en/models/associations-linking-models-together.html# - * @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/association-mapping.html - * - * @see \Rector\CakePHPToSymfony\Tests\Rector\Class_\CakePHPModelToDoctrineEntityRector\CakePHPModelToDoctrineEntityRectorTest - */ -final class CakePHPModelToDoctrineEntityRector extends AbstractRector -{ - /** - * @var RelationPropertyFactory - */ - private $relationPropertyFactory; - - public function __construct(RelationPropertyFactory $relationPropertyFactory) - { - $this->relationPropertyFactory = $relationPropertyFactory; - } - - public function getDefinition(): RectorDefinition - { - return new RectorDefinition('Migrate CakePHP Model active record to Doctrine\ORM Entity and EntityRepository', [ - new CodeSample( - <<<'PHP' -class Activity extends \AppModel -{ - public $belongsTo = [ - 'ActivityType' => [ - 'className' => 'ActivityType', - 'foreignKey' => 'activity_type_id', - 'dependent' => false, - ], - ]; -} -PHP -, - <<<'PHP' -use Doctrine\Mapping\Annotation as ORM; - -/** - * @ORM\Entity - */ -class Activity -{ - /** - * @ORM\ManyToOne(targetEntity="ActivityType") - * @ORM\JoinColumn(name="activity_type_id") - */ - private $activityType; -} -PHP - - ), - ]); - } - - /** - * @return string[] - */ - public function getNodeTypes(): array - { - return [Class_::class]; - } - - /** - * @param Class_ $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->isObjectType($node, 'AppModel')) { - return null; - } - - $node->extends = null; - $this->addEntityTagToEntityClass($node); - - $relationProperties = []; - - // extract relations - $belongsToProperty = $node->getProperty('belongsTo'); - if ($belongsToProperty !== null) { - $manyToOneProperties = $this->relationPropertyFactory->createManyToOneProperties($belongsToProperty); - $relationProperties = array_merge($relationProperties, $manyToOneProperties); - - $this->removeNode($belongsToProperty); - } - - $hasAndBelongsToManyProperty = $node->getProperty('hasAndBelongsToMany'); - if ($hasAndBelongsToManyProperty !== null) { - $newRelationProperties = $this->relationPropertyFactory->createManyToManyProperties( - $hasAndBelongsToManyProperty - ); - $relationProperties = array_merge($relationProperties, $newRelationProperties); - - $this->removeNode($hasAndBelongsToManyProperty); - } - - $hasManyProperty = $node->getProperty('hasMany'); - if ($hasManyProperty !== null) { - $newRelationProperties = $this->relationPropertyFactory->createOneToManyProperties($hasManyProperty); - $relationProperties = array_merge($relationProperties, $newRelationProperties); - - $this->removeNode($hasManyProperty); - } - - $hasOneProperty = $node->getProperty('hasOne'); - if ($hasOneProperty !== null) { - $newRelationProperties = $this->relationPropertyFactory->createOneToOneProperties($hasOneProperty); - $relationProperties = array_merge($relationProperties, $newRelationProperties); - - $this->removeNode($hasOneProperty); - } - - if ($relationProperties !== []) { - $node->stmts = array_merge($relationProperties, (array) $node->stmts); - } - - return $node; - } - - private function addEntityTagToEntityClass(Class_ $class): void - { - /** @var PhpDocInfo $phpDocInfo */ - $phpDocInfo = $class->getAttribute(AttributeKey::PHP_DOC_INFO); - $phpDocInfo->addTagValueNodeWithShortName(new EntityTagValueNode([])); - - $objectType = new AliasedObjectType('ORM', 'Doctrine\Mapping\Annotation'); - $this->addUseType($objectType, $class); - } -} diff --git a/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPModelToDoctrineRepositoryRector.php b/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPModelToDoctrineRepositoryRector.php deleted file mode 100644 index a82bc62e810f..000000000000 --- a/rules/cakephp-to-symfony/src/Rector/Class_/CakePHPModelToDoctrineRepositoryRector.php +++ /dev/null @@ -1,268 +0,0 @@ -doctrineRepositoryClassMethodManipulator = $doctrineRepositoryClassMethodManipulator; - $this->doctrineNodeFactory = $doctrineNodeFactory; - } - - public function getDefinition(): RectorDefinition - { - return new RectorDefinition( - 'Migrate CakePHP Model active record to Doctrine\ORM\Repository with repository/DQL method calls', - [ - new CodeSample( - <<<'PHP' -class Activity extends \AppModel -{ - public function getAll() - { - $result = $this->find('all'); - - return $result; - } - - public function getOne() - { - $result = $this->find('first', [ - 'conditions' => [ - 'DocumentVersionsSave.revision_number' => $versionId, - 'DocumentVersionsSave.document_id' => $documentId, - ], - 'order' => [ - 'created DESC', - ], - ]); - - return $result; - } -} -PHP -, - <<<'PHP' -use Doctrine\ORM\EntityManagerInterface; - -class Activity -{ -} - -class ActivityRepository -{ - /** - * @var EntityManagerInterface - */ - private $repository; - - public function __construct(EntityManagerInterface $entityManager) - { - $this->repository = $entityManager->getRepository(Activity::class); - } - - public function getAll() - { - $result = $this->repository->findAll(); - - return $result; - } - - public function getOne() - { - $result = $this->findOneBy([ - 'revision_number' => $versionId, - 'document_id' => $documentId, - ], 'created DESC'); - - return $result; - } -} -PHP - - ), - ] - ); - } - - /** - * @return string[] - */ - public function getNodeTypes(): array - { - return [Class_::class]; - } - - /** - * @param Class_ $node - */ - public function refactor(Node $node): ?Node - { - if (! $this->isInCakePHPController($node)) { - return null; - } - - $repositoryMethods = $this->getRepositoryMethods($node); - if ($repositoryMethods === []) { - return null; - } - - // 1. create repository class - $repositoryClass = $this->createRepositoryClass($node, $repositoryMethods); - - // 2. save repository class - $nodeToPrint = $this->createNodeToPrint($node, $repositoryClass); - - $repositoryFilePath = $this->createRepositoryFilePath($node); - $this->printToFile($nodeToPrint, $repositoryFilePath); - - // 3.remove repository class methods - foreach ($repositoryMethods as $repositoryMethod) { - $this->removeNode($repositoryMethod); - } - - $node->extends = null; - - return $node; - } - - /** - * @return ClassMethod[] - */ - private function getRepositoryMethods(Class_ $class): array - { - $repositoryMethods = []; - - foreach ($class->getMethods() as $classMethod) { - if (! $this->inRepositoryMethod($classMethod)) { - continue; - } - - $repositoryMethods[] = $classMethod; - } - - return $repositoryMethods; - } - - /** - * @param ClassMethod[] $repositoryMethods - */ - private function createRepositoryClass(Class_ $class, array $repositoryMethods): Class_ - { - $repositoryClassName = $this->getRepositoryShortClassName($class); - $repositoryClass = new Class_($repositoryClassName); - - $repositoryClass->stmts[] = $this->doctrineNodeFactory->createRepositoryProperty(); - - $entityClass = $this->getName($class->name); - assert(is_string($entityClass)); - - $repositoryClass->stmts[] = $this->doctrineNodeFactory->createConstructorWithGetRepositoryAssign($entityClass); - - foreach ($repositoryMethods as $repositoryMethod) { - $doctrineRepositoryClassMethod = $this->doctrineRepositoryClassMethodManipulator->createFromCakePHPClassMethod( - $repositoryMethod, - $entityClass - ); - $repositoryClass->stmts[] = $doctrineRepositoryClassMethod; - } - - return $repositoryClass; - } - - private function createNodeToPrint(Class_ $class, Class_ $repositoryClass): Node - { - /** @var Namespace_|null $namespaceNode */ - $namespaceNode = $class->getAttribute(AttributeKey::NAMESPACE_NODE); - if ($namespaceNode !== null) { - $namespaceNode->stmts = [$repositoryClass]; - return $namespaceNode; - } - - return $repositoryClass; - } - - private function createRepositoryFilePath(Class_ $class): string - { - $repositoryClassName = $this->getRepositoryShortClassName($class); - - /** @var SmartFileInfo $fileInfo */ - $fileInfo = $class->getAttribute(AttributeKey::FILE_INFO); - - return $fileInfo->getRelativeDirectoryPath() . '/' . $repositoryClassName . '.php'; - } - - /** - * Looks for "$this->find()" call - */ - private function inRepositoryMethod(ClassMethod $classMethod): bool - { - $isRepositoryMethod = false; - - $this->traverseNodesWithCallable((array) $classMethod->getStmts(), function (Node $node) use ( - &$isRepositoryMethod - ) { - if (! $node instanceof MethodCall) { - return null; - } - - if (! $this->isObjectType($node->var, 'AppModel')) { - return null; - } - - if (! $this->isName($node->name, 'find')) { - return null; - } - - $isRepositoryMethod = true; - - return NodeTraverser::STOP_TRAVERSAL; - }); - - return $isRepositoryMethod; - } - - private function getRepositoryShortClassName(Class_ $class): string - { - /** @var string $classShortName */ - $classShortName = $class->getAttribute(AttributeKey::CLASS_SHORT_NAME); - - return $classShortName . 'Repository'; - } -} diff --git a/rules/cakephp-to-symfony/src/Rector/Echo_/CakePHPTemplateHToTwigRector.php b/rules/cakephp-to-symfony/src/Rector/Echo_/CakePHPTemplateHToTwigRector.php deleted file mode 100644 index 0030d859ba68..000000000000 --- a/rules/cakephp-to-symfony/src/Rector/Echo_/CakePHPTemplateHToTwigRector.php +++ /dev/null @@ -1,66 +0,0 @@ -', '

    {{ value|escape }}

    '), - ]); - } - - /** - * @return string[] - */ - public function getNodeTypes(): array - { - return [Echo_::class]; - } - - /** - * @param Echo_ $node - */ - public function refactor(Node $node): ?Node - { - if (! isset($node->exprs[0])) { - return null; - } - - $singleEchoedExpr = $node->exprs[0]; - if (! $singleEchoedExpr instanceof FuncCall) { - return null; - } - - if (! $this->isName($singleEchoedExpr, 'h')) { - return null; - } - - $funcArg = $singleEchoedExpr->args[0]->value; - if ($funcArg instanceof Variable) { - $templateVariable = $this->getName($funcArg); - } else { - throw new NotImplementedException(); - } - - $htmlContent = sprintf('{{ %s|escape }}', $templateVariable); - - return new InlineHTML($htmlContent); - } -} diff --git a/rules/cakephp-to-symfony/src/Rector/Echo_/CakePHPTemplateLinkToTwigRector.php b/rules/cakephp-to-symfony/src/Rector/Echo_/CakePHPTemplateLinkToTwigRector.php deleted file mode 100644 index ecedc7467125..000000000000 --- a/rules/cakephp-to-symfony/src/Rector/Echo_/CakePHPTemplateLinkToTwigRector.php +++ /dev/null @@ -1,129 +0,0 @@ -routeResolver = $routeResolver; - } - - public function getDefinition(): RectorDefinition - { - return new RectorDefinition('Migrate CakePHP 2.4 template method calls to Twig', [ - new CodeSample( - <<<'PHP' -
  • - Html->link('List Rights', ['action' => 'index']); ?> -
  • -PHP -, - <<<'PHP' -
  • - List Rights -
  • -PHP - - ), - ]); - } - - /** - * @return string[] - */ - public function getNodeTypes(): array - { - return [Echo_::class]; - } - - /** - * @param Echo_ $node - */ - public function refactor(Node $node): ?Node - { - $firstExpression = $node->exprs[0]; - if (! $firstExpression instanceof MethodCall) { - return null; - } - - if (! $this->isThisHtmlPropertyFetch($firstExpression->var)) { - return null; - } - - $label = $firstExpression->args[0]->value; - $parameters = $firstExpression->args[1]->value; - - # e.g. |trans https://symfony.com/doc/current/translation/templates.html#using-twig-filters - $labelFilters = []; - if ($this->isFuncCallName($label, '__')) { - $labelFilters[] = 'trans'; - $label = $label->args[0]->value; - } - - $parametersValue = $this->getValue($parameters); - - /** @var SmartFileInfo|null $fileInfo */ - $fileInfo = $node->getAttribute(AttributeKey::FILE_INFO); - assert($fileInfo instanceof SmartFileInfo); - - $routeName = $this->routeResolver->resolveFromParamsAndFileInfo($parametersValue, $fileInfo); - $labelValue = $this->getValue($label); - assert(is_string($labelValue)); - - $aHtml = $this->createAHtml($routeName, $labelFilters, $labelValue); - return new InlineHTML($aHtml); - } - - private function isThisHtmlPropertyFetch(Expr $expr): bool - { - if (! $expr instanceof PropertyFetch) { - return false; - } - - if (! $this->isName($expr->var, 'this')) { - return false; - } - return $this->isName($expr->name, 'Html'); - } - - private function createAHtml(string $routeName, array $labelFilters, string $labelValue): string - { - $aHtml = Html::el('a'); - $aHtml->href = sprintf("{{ path('%s') }}", $routeName); - - if ($labelFilters !== []) { - $labelFilterAsString = implode('|', $labelFilters); - - $labelValue = sprintf("{{ '%s'|%s }}", $labelValue, $labelFilterAsString); - } - - $aHtml->setText($labelValue); - - return $aHtml->toHtml(); - } -} diff --git a/rules/cakephp-to-symfony/src/Rector/Echo_/CakePHPTemplateTranslateToTwigRector.php b/rules/cakephp-to-symfony/src/Rector/Echo_/CakePHPTemplateTranslateToTwigRector.php deleted file mode 100644 index 723677b27f68..000000000000 --- a/rules/cakephp-to-symfony/src/Rector/Echo_/CakePHPTemplateTranslateToTwigRector.php +++ /dev/null @@ -1,56 +0,0 @@ -', '

    {{ "Actions"|trans }}

    '), - ]); - } - - /** - * @return string[] - */ - public function getNodeTypes(): array - { - return [Echo_::class]; - } - - /** - * @param Echo_ $node - */ - public function refactor(Node $node): ?Node - { - $expr = $node->exprs[0]; - if (! $expr instanceof FuncCall) { - return null; - } - - if (! $this->isName($expr, '__')) { - return null; - } - - $translatedValue = $expr->args[0]->value; - $translatedValue = $this->getValue($translatedValue); - - $html = sprintf("{{ '%s'|trans }}", $translatedValue); - - return new InlineHTML($html); - } -} diff --git a/rules/cakephp-to-symfony/src/RouteResolver.php b/rules/cakephp-to-symfony/src/RouteResolver.php deleted file mode 100644 index 491bcc640f4a..000000000000 --- a/rules/cakephp-to-symfony/src/RouteResolver.php +++ /dev/null @@ -1,41 +0,0 @@ -getPath(), '/', -1); - if (! is_string($shortDirectoryName)) { - throw new ShouldNotHappenException(); - } - - $shortDirectoryNameUnderscored = StaticRectorStrings::camelCaseToUnderscore($shortDirectoryName); - - return $shortDirectoryNameUnderscored . '_' . $actionUnderscored; - } - - return $routeName; - } -} diff --git a/rules/cakephp-to-symfony/src/Template/TemplateMethodCallManipulator.php b/rules/cakephp-to-symfony/src/Template/TemplateMethodCallManipulator.php deleted file mode 100644 index 5c2a91506a88..000000000000 --- a/rules/cakephp-to-symfony/src/Template/TemplateMethodCallManipulator.php +++ /dev/null @@ -1,130 +0,0 @@ -valueResolver = $valueResolver; - $this->templatePathResolver = $templatePathResolver; - $this->callableNodeTraverser = $callableNodeTraverser; - $this->nodeNameResolver = $nodeNameResolver; - } - - public function refactorExistingRenderMethodCall(ClassMethod $classMethod): void - { - $controllerNamePart = $this->templatePathResolver->resolveClassNameTemplatePart($classMethod); - - $this->callableNodeTraverser->traverseNodesWithCallable($classMethod, function (Node $node) use ( - $controllerNamePart - ) { - $renderMethodCall = $this->matchThisRenderMethodCallBareOrInReturn($node); - if ($renderMethodCall === null) { - return null; - } - - return $this->refactorRenderTemplateName($renderMethodCall, $controllerNamePart); - }); - } - - private function matchThisRenderMethodCallBareOrInReturn(Node $node): ?MethodCall - { - if ($node instanceof Return_) { - $nodeExpr = $node->expr; - if ($nodeExpr === null) { - return null; - } - - if (! $this->isThisRenderMethodCall($nodeExpr)) { - return null; - } - - /** @var MethodCall $nodeExpr */ - return $nodeExpr; - } - - if ($node instanceof Expression) { - if (! $this->isThisRenderMethodCall($node->expr)) { - return null; - } - - return $node->expr; - } - - return null; - } - - private function refactorRenderTemplateName(Node $node, string $controllerNamePart): ?Return_ - { - /** @var MethodCall $node */ - $renderArgumentValue = $this->valueResolver->getValue($node->args[0]->value); - - /** @var string|mixed $renderArgumentValue */ - if (! is_string($renderArgumentValue)) { - return null; - } - - if (Strings::contains($renderArgumentValue, '/')) { - $templateName = $renderArgumentValue . '.twig'; - } else { - // add explicit controller - $templateName = $controllerNamePart . '/' . $renderArgumentValue . '.twig'; - } - - $node->args[0]->value = new String_($templateName); - - return new Return_($node); - } - - private function isThisRenderMethodCall(Node $node): bool - { - if (! $node instanceof MethodCall) { - return false; - } - - if (! $this->nodeNameResolver->isName($node->var, 'this')) { - return false; - } - - return $this->nodeNameResolver->isName($node->name, 'render'); - } -} diff --git a/rules/cakephp-to-symfony/src/TemplatePathResolver.php b/rules/cakephp-to-symfony/src/TemplatePathResolver.php deleted file mode 100644 index 5bf3a7cc205d..000000000000 --- a/rules/cakephp-to-symfony/src/TemplatePathResolver.php +++ /dev/null @@ -1,112 +0,0 @@ -callableNodeTraverser = $callableNodeTraverser; - $this->propertyFetchManipulator = $propertyFetchManipulator; - $this->valueResolver = $valueResolver; - $this->nodesToRemoveCollector = $nodesToRemoveCollector; - } - - public function resolveForClassMethod(ClassMethod $classMethod): string - { - $viewPropertyValue = $this->resolveViewPropertyValue($classMethod); - if ($viewPropertyValue !== null) { - $viewPropertyValue = Strings::lower($viewPropertyValue); - return $viewPropertyValue . '.twig'; - } - - $classAndMethodValue = $this->resolveFromClassAndMethod($classMethod); - - return $classAndMethodValue . '.twig'; - } - - public function resolveClassNameTemplatePart(ClassMethod $classMethod): string - { - /** @var string $shortClassName */ - $shortClassName = $classMethod->getAttribute(AttributeKey::CLASS_SHORT_NAME); - $shortClassName = Strings::replace($shortClassName, '#Controller$#i'); - - return Strings::lower($shortClassName); - } - - private function resolveViewPropertyValue(ClassMethod $classMethod): ?string - { - $setViewProperty = null; - - $this->callableNodeTraverser->traverseNodesWithCallable($classMethod, function (Node $node) use ( - &$setViewProperty - ) { - if (! $node instanceof Assign) { - return null; - } - - if (! $this->propertyFetchManipulator->isToThisPropertyFetchOfSpecificNameAssign($node, 'view')) { - return null; - } - - $setViewProperty = $node->expr; - - $this->nodesToRemoveCollector->addNodeToRemove($node); - }); - - if ($setViewProperty === null) { - return null; - } - - $setViewValue = $this->valueResolver->getValue($setViewProperty); - if (is_string($setViewValue)) { - return Strings::lower($setViewValue); - } - - return null; - } - - private function resolveFromClassAndMethod(ClassMethod $classMethod): string - { - $shortClassName = $this->resolveClassNameTemplatePart($classMethod); - $methodName = $classMethod->getAttribute(AttributeKey::METHOD_NAME); - - return $shortClassName . '/' . $methodName; - } -} diff --git a/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerActionToSymfonyControllerActionRector/CakePHPControllerActionToSymfonyControllerActionRectorTest.php b/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerActionToSymfonyControllerActionRector/CakePHPControllerActionToSymfonyControllerActionRectorTest.php deleted file mode 100644 index c4c8eced01cf..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerActionToSymfonyControllerActionRector/CakePHPControllerActionToSymfonyControllerActionRectorTest.php +++ /dev/null @@ -1,30 +0,0 @@ -doTestFile($file); - } - - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return CakePHPControllerActionToSymfonyControllerActionRector::class; - } -} diff --git a/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerActionToSymfonyControllerActionRector/Fixture/fixture.php.inc b/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerActionToSymfonyControllerActionRector/Fixture/fixture.php.inc deleted file mode 100644 index f0ac934fabb6..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerActionToSymfonyControllerActionRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,27 +0,0 @@ - ------ - diff --git a/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRedirectToSymfonyRector/CakePHPControllerRedirectToSymfonyRectorTest.php b/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRedirectToSymfonyRector/CakePHPControllerRedirectToSymfonyRectorTest.php deleted file mode 100644 index 902d3200fc1c..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRedirectToSymfonyRector/CakePHPControllerRedirectToSymfonyRectorTest.php +++ /dev/null @@ -1,30 +0,0 @@ -doTestFile($file); - } - - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return CakePHPControllerRedirectToSymfonyRector::class; - } -} diff --git a/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRedirectToSymfonyRector/Fixture/fixture.php.inc b/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRedirectToSymfonyRector/Fixture/fixture.php.inc deleted file mode 100644 index c5027ea9626f..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRedirectToSymfonyRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,27 +0,0 @@ -redirect('boom'); - } -} - -?> ------ -redirect('boom'); - } -} - -?> diff --git a/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRedirectToSymfonyRector/Fixture/redirect_to_controller.php.inc b/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRedirectToSymfonyRector/Fixture/redirect_to_controller.php.inc deleted file mode 100644 index be8591912e68..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRedirectToSymfonyRector/Fixture/redirect_to_controller.php.inc +++ /dev/null @@ -1,30 +0,0 @@ -redirect([ - 'controller' => 'DocumentVersions', - 'action' => 'getFile' - ]); - } -} - -?> ------ -redirectToRoute('document_versions_get_file'); - } -} - -?> diff --git a/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector/CakePHPControllerRenderToSymfonyRectorTest.php b/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector/CakePHPControllerRenderToSymfonyRectorTest.php deleted file mode 100644 index 181d9dd78363..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector/CakePHPControllerRenderToSymfonyRectorTest.php +++ /dev/null @@ -1,30 +0,0 @@ -doTestFile($file); - } - - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return CakePHPControllerRenderToSymfonyRector::class; - } -} diff --git a/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector/Fixture/changed_view_property.php.inc b/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector/Fixture/changed_view_property.php.inc deleted file mode 100644 index 5740ce2772a6..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector/Fixture/changed_view_property.php.inc +++ /dev/null @@ -1,27 +0,0 @@ -view = 'Controller/this_value'; - } -} - -?> ------ -render('controller/this_value.twig'); - } -} - -?> diff --git a/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector/Fixture/compact_too.php.inc b/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector/Fixture/compact_too.php.inc deleted file mode 100644 index 1c635cddd030..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector/Fixture/compact_too.php.inc +++ /dev/null @@ -1,27 +0,0 @@ -set(compact('clientId', 'states', 'invoiceTemplates')); - } -} - -?> ------ -render('compacttoo/index.twig', ['clientId' => $clientId, 'states' => $states, 'invoiceTemplates' => $invoiceTemplates]); - } -} - -?> diff --git a/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector/Fixture/fixture.php.inc b/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector/Fixture/fixture.php.inc deleted file mode 100644 index 13e924726fce..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,27 +0,0 @@ -render('custom_file'); - } -} - -?> ------ -render('redirect/custom_file.twig'); - } -} - -?> diff --git a/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector/Fixture/set.php.inc b/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector/Fixture/set.php.inc deleted file mode 100644 index 21b269b2c845..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/ClassMethod/CakePHPControllerRenderToSymfonyRector/Fixture/set.php.inc +++ /dev/null @@ -1,27 +0,0 @@ -set('name', 5); - } -} - -?> ------ -render('set/index.twig', ['name' => 5]); - } -} - -?> diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPBeforeFilterToRequestEventSubscriberRector/CakePHPBeforeFilterToRequestEventSubscriberRectorExtraTest.php b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPBeforeFilterToRequestEventSubscriberRector/CakePHPBeforeFilterToRequestEventSubscriberRectorExtraTest.php deleted file mode 100644 index faa08c0808b8..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPBeforeFilterToRequestEventSubscriberRector/CakePHPBeforeFilterToRequestEventSubscriberRectorExtraTest.php +++ /dev/null @@ -1,35 +0,0 @@ -doTestFile($inputFile); - $this->doTestExtraFile($expectedExtraFileName, $expectedExtraContentFilePath); - } - - public function provideData(): Iterator - { - yield [ - __DIR__ . '/Fixture/fixture.php.inc', - 'SuperadminControllerEventSubscriber.php', - __DIR__ . '/Source/extra_file.php', - ]; - } - - protected function getRectorClass(): string - { - return CakePHPBeforeFilterToRequestEventSubscriberRector::class; - } -} diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPBeforeFilterToRequestEventSubscriberRector/Fixture/fixture.php.inc b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPBeforeFilterToRequestEventSubscriberRector/Fixture/fixture.php.inc deleted file mode 100644 index 2630a5114c42..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPBeforeFilterToRequestEventSubscriberRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,23 +0,0 @@ - ------ - diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPBeforeFilterToRequestEventSubscriberRector/Source/extra_file.php b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPBeforeFilterToRequestEventSubscriberRector/Source/extra_file.php deleted file mode 100644 index 7f1993192fed..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPBeforeFilterToRequestEventSubscriberRector/Source/extra_file.php +++ /dev/null @@ -1,15 +0,0 @@ - 'onKernelRequest']; - } - public function onKernelRequest() - { - // something - } -} diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPBeforeFilterToRequestEventSubscriberRector/Source/extra_file_after.php b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPBeforeFilterToRequestEventSubscriberRector/Source/extra_file_after.php deleted file mode 100644 index f76d07dc8346..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPBeforeFilterToRequestEventSubscriberRector/Source/extra_file_after.php +++ /dev/null @@ -1,22 +0,0 @@ - 'onKernelRequest', - ]; - } - - public function onKernelRequest() - { - // something - } -} - diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerComponentToSymfonyRector/CakePHPControllerComponentToSymfonyRectorTest.php b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerComponentToSymfonyRector/CakePHPControllerComponentToSymfonyRectorTest.php deleted file mode 100644 index 9d29cef4c769..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerComponentToSymfonyRector/CakePHPControllerComponentToSymfonyRectorTest.php +++ /dev/null @@ -1,30 +0,0 @@ -doTestFile($file); - } - - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return CakePHPControllerComponentToSymfonyRector::class; - } -} diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerComponentToSymfonyRector/Fixture/fixture.php.inc b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerComponentToSymfonyRector/Fixture/fixture.php.inc deleted file mode 100644 index 522db5d8d346..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerComponentToSymfonyRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,51 +0,0 @@ -Overview->filter(); - } -} - -class OverviewComponent extends \Component -{ - public function filter() - { - } -} - -?> ------ -overviewComponent = $overviewComponent; - } - public function someAction() - { - $this->overviewComponent->filter(); - } -} - -class OverviewComponent extends \Component -{ - public function filter() - { - } -} - -?> diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerComponentToSymfonyRector/Source/Component.php b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerComponentToSymfonyRector/Source/Component.php deleted file mode 100644 index f3b370c1fa6e..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerComponentToSymfonyRector/Source/Component.php +++ /dev/null @@ -1,8 +0,0 @@ -doTestFile($file); - } - - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return CakePHPControllerHelperToSymfonyRector::class; - } -} diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerHelperToSymfonyRector/Fixture/fixture.php.inc b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerHelperToSymfonyRector/Fixture/fixture.php.inc deleted file mode 100644 index 6530f12cfb92..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerHelperToSymfonyRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,31 +0,0 @@ -Flash->success(__('Your post has been saved.')); - $this->Flash->error(__('Unable to add your post.')); - } -} - -?> ------ -addFlash('success', __('Your post has been saved.')); - $this->addFlash('error', __('Unable to add your post.')); - } -} - -?> diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerToSymfonyControllerRector/CakePHPControllerToSymfonyControllerRectorTest.php b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerToSymfonyControllerRector/CakePHPControllerToSymfonyControllerRectorTest.php deleted file mode 100644 index 12a5cbf012db..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerToSymfonyControllerRector/CakePHPControllerToSymfonyControllerRectorTest.php +++ /dev/null @@ -1,30 +0,0 @@ -doTestFile($file); - } - - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return CakePHPControllerToSymfonyControllerRector::class; - } -} diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerToSymfonyControllerRector/Fixture/fixture.php.inc b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerToSymfonyControllerRector/Fixture/fixture.php.inc deleted file mode 100644 index 7562300b7395..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPControllerToSymfonyControllerRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,25 +0,0 @@ - ------ - diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPImplicitRouteToExplicitRouteAnnotationRector/CakePHPImplicitRouteToExplicitRouteAnnotationRectorTest.php b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPImplicitRouteToExplicitRouteAnnotationRector/CakePHPImplicitRouteToExplicitRouteAnnotationRectorTest.php deleted file mode 100644 index aa16d559351b..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPImplicitRouteToExplicitRouteAnnotationRector/CakePHPImplicitRouteToExplicitRouteAnnotationRectorTest.php +++ /dev/null @@ -1,30 +0,0 @@ -doTestFile($file); - } - - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return CakePHPImplicitRouteToExplicitRouteAnnotationRector::class; - } -} diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPImplicitRouteToExplicitRouteAnnotationRector/Fixture/fixture.php.inc b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPImplicitRouteToExplicitRouteAnnotationRector/Fixture/fixture.php.inc deleted file mode 100644 index eda68284dd3a..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPImplicitRouteToExplicitRouteAnnotationRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,29 +0,0 @@ - ------ - diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPImplicitRouteToExplicitRouteAnnotationRector/Fixture/skip_private.php.inc b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPImplicitRouteToExplicitRouteAnnotationRector/Fixture/skip_private.php.inc deleted file mode 100644 index a81833440c55..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPImplicitRouteToExplicitRouteAnnotationRector/Fixture/skip_private.php.inc +++ /dev/null @@ -1,10 +0,0 @@ -doTestFile($file); - } - - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return CakePHPModelToDoctrineEntityRector::class; - } -} diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/Fixture/belongs_to.php.inc b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/Fixture/belongs_to.php.inc deleted file mode 100644 index 101b27436e11..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/Fixture/belongs_to.php.inc +++ /dev/null @@ -1,35 +0,0 @@ - [ - 'className' => 'ActivityType', - 'foreignKey' => 'activity_type_id', - 'dependent' => false, - ], - ]; -} - -?> ------ - diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/Fixture/has_many.php.inc b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/Fixture/has_many.php.inc deleted file mode 100644 index 2d17cda19c65..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/Fixture/has_many.php.inc +++ /dev/null @@ -1,32 +0,0 @@ - [ - 'className' => 'HasManyType', - ], - ]; -} - -?> ------ - diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/Fixture/has_many_and_belongs_to_many.php.inc b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/Fixture/has_many_and_belongs_to_many.php.inc deleted file mode 100644 index e5c4102966b6..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/Fixture/has_many_and_belongs_to_many.php.inc +++ /dev/null @@ -1,32 +0,0 @@ - [ - 'className' => 'Group', - ] - ]; -} - -?> ------ - diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/Fixture/has_one.php.inc b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/Fixture/has_one.php.inc deleted file mode 100644 index 9c14297c3200..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/Fixture/has_one.php.inc +++ /dev/null @@ -1,32 +0,0 @@ - [ - 'className' => 'HasOneType', - ], - ]; -} - -?> ------ - diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/Source/AppModel.php b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/Source/AppModel.php deleted file mode 100644 index d34250045bb1..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineEntityRector/Source/AppModel.php +++ /dev/null @@ -1,8 +0,0 @@ -doTestFile($file); - - $this->assertFileExists($expectedRepositoryFilePath); - $this->assertFileEquals($expectedRepositoryContentFile, $expectedRepositoryFilePath); - } - - public function provideData(): Iterator - { - yield [ - __DIR__ . '/Fixture/find_first.php.inc', - $this->getTempPath() . '/FindFirstRepository.php', - __DIR__ . '/Source/ExpectedFindFirstRepository.php', - ]; - - yield [ - __DIR__ . '/Fixture/find_all.php.inc', - $this->getTempPath() . '/FindAllRepository.php', - __DIR__ . '/Source/ExpectedFindAllRepository.php', - ]; - - yield [ - __DIR__ . '/Fixture/find_threaded.php.inc', - $this->getTempPath() . '/FindThreadedRepository.php', - __DIR__ . '/Source/ExpectedFindThreadedRepository.php', - ]; - - yield [ - __DIR__ . '/Fixture/find_count.php.inc', - $this->getTempPath() . '/FindCountRepository.php', - __DIR__ . '/Source/ExpectedFindCountRepository.php', - ]; - - yield [ - __DIR__ . '/Fixture/find_list.php.inc', - $this->getTempPath() . '/FindListRepository.php', - __DIR__ . '/Source/ExpectedFindListRepository.php', - ]; - -// WIP -// yield [ -// __DIR__ . '/Fixture/find_list_with_one_argument.php.inc', -// $this->getTempPath() . '/FindListWithOneArgumentRepository.php', -// __DIR__ . '/Source/ExpectedFindListWithOneArgumentRepository.php', -// ]; - } - - protected function getRectorClass(): string - { - return CakePHPModelToDoctrineRepositoryRector::class; - } -} diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture/find_all.php.inc b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture/find_all.php.inc deleted file mode 100644 index 72758f626329..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture/find_all.php.inc +++ /dev/null @@ -1,25 +0,0 @@ -find('all'); - - return $result; - } -} - -?> ------ - diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture/find_count.php.inc b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture/find_count.php.inc deleted file mode 100644 index 9185d34330b5..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture/find_count.php.inc +++ /dev/null @@ -1,25 +0,0 @@ -find('count', [ - 'conditions' => ['article_id' => 50] - ]); - } -} - -?> ------ - diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture/find_first.php.inc b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture/find_first.php.inc deleted file mode 100644 index 46cd874422ac..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture/find_first.php.inc +++ /dev/null @@ -1,33 +0,0 @@ -find('first', [ - 'conditions' => [ - 'FindFirst.revision_number' => $versionId, - 'FindFirst.document_id' => $documentId, - ], - 'order' => [ - 'created DESC', - ], - ]); - - return $result; - } -} - -?> ------ - diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture/find_list.php.inc b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture/find_list.php.inc deleted file mode 100644 index 84eef66e02c3..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture/find_list.php.inc +++ /dev/null @@ -1,23 +0,0 @@ -find('list'); - } -} - -?> ------ - diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture/find_list_with_one_argument.php.inc b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture/find_list_with_one_argument.php.inc deleted file mode 100644 index 378ddb4e4d05..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture/find_list_with_one_argument.php.inc +++ /dev/null @@ -1,25 +0,0 @@ -find('list', [ - 'fields' => ['User.username'] - ]); - } -} - -?> ------ - diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture/find_threaded.php.inc b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture/find_threaded.php.inc deleted file mode 100644 index 1f06aff4e6ca..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Fixture/find_threaded.php.inc +++ /dev/null @@ -1,25 +0,0 @@ -find('threaded', [ - 'conditions' => ['article_id' => 50] - ]); - } -} - -?> ------ - diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Source/ExpectedFindAllRepository.php b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Source/ExpectedFindAllRepository.php deleted file mode 100644 index ca97baa2621b..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Source/ExpectedFindAllRepository.php +++ /dev/null @@ -1,20 +0,0 @@ -repository = $entityManager->getRepository(\FindAll::class); - } - public function getAll() - { - $result = $this->repository->findAll(); - return $result; - } -} diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Source/ExpectedFindCountRepository.php b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Source/ExpectedFindCountRepository.php deleted file mode 100644 index 8fd7fd48a93d..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Source/ExpectedFindCountRepository.php +++ /dev/null @@ -1,19 +0,0 @@ -repository = $entityManager->getRepository(\FindCount::class); - } - public function getAll() - { - return $this->repository->count(['article_id' => 50]); - } -} diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Source/ExpectedFindFirstRepository.php b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Source/ExpectedFindFirstRepository.php deleted file mode 100644 index 1f3c328878d5..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Source/ExpectedFindFirstRepository.php +++ /dev/null @@ -1,20 +0,0 @@ -repository = $entityManager->getRepository(\FindFirst::class); - } - public function getOne() - { - $result = $this->repository->findOneBy(['revision_number' => $versionId, 'document_id' => $documentId], 'created DESC'); - return $result; - } -} diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Source/ExpectedFindListRepository.php b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Source/ExpectedFindListRepository.php deleted file mode 100644 index b124c8a4f059..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Source/ExpectedFindListRepository.php +++ /dev/null @@ -1,19 +0,0 @@ -repository = $entityManager->getRepository(\FindList::class); - } - public function getList() - { - return $this->repository->createQueryBuilder('f')->getQuery()->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY); - } -} diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Source/ExpectedFindListWithOneArgumentRepository.php b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Source/ExpectedFindListWithOneArgumentRepository.php deleted file mode 100644 index 85773f3ae266..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Source/ExpectedFindListWithOneArgumentRepository.php +++ /dev/null @@ -1,19 +0,0 @@ -repository = $entityManager->getRepository(\FindListWithOneArgument::class); - } - public function getList() - { - return $this->repository->createQueryBuilder('f')->getQuery()->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY); - } -} diff --git a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Source/ExpectedFindThreadedRepository.php b/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Source/ExpectedFindThreadedRepository.php deleted file mode 100644 index bc4250794f35..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Class_/CakePHPModelToDoctrineRepositoryRector/Source/ExpectedFindThreadedRepository.php +++ /dev/null @@ -1,19 +0,0 @@ -repository = $entityManager->getRepository(\FindThreaded::class); - } - public function getAll() - { - return $this->repository->findBy(['article_id' => 50]); - } -} diff --git a/rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateHToTwigRector/CakePHPTemplateHToTwigRectorTest.php b/rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateHToTwigRector/CakePHPTemplateHToTwigRectorTest.php deleted file mode 100644 index c457ab34a495..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateHToTwigRector/CakePHPTemplateHToTwigRectorTest.php +++ /dev/null @@ -1,30 +0,0 @@ -doTestFileWithoutAutoload($file); - } - - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return CakePHPTemplateHToTwigRector::class; - } -} diff --git a/rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateHToTwigRector/Fixture/html_fixture.php.inc b/rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateHToTwigRector/Fixture/html_fixture.php.inc deleted file mode 100644 index a39900c1e935..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateHToTwigRector/Fixture/html_fixture.php.inc +++ /dev/null @@ -1,3 +0,0 @@ -

    ------ -

    {{ value|escape }}

    diff --git a/rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateLinkToTwigRector/CakePHPTemplateToTwigRectorTest.php b/rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateLinkToTwigRector/CakePHPTemplateToTwigRectorTest.php deleted file mode 100644 index 84e432ee0625..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateLinkToTwigRector/CakePHPTemplateToTwigRectorTest.php +++ /dev/null @@ -1,30 +0,0 @@ -doTestFileWithoutAutoload($file); - } - - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return CakePHPTemplateLinkToTwigRector::class; - } -} diff --git a/rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateLinkToTwigRector/Fixture/fixture.php.inc b/rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateLinkToTwigRector/Fixture/fixture.php.inc deleted file mode 100644 index a7bcf0f7f2c0..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateLinkToTwigRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,7 +0,0 @@ -
  • - Html->link(__('List Rights'), ['action' => 'index']); ?> -
  • ------ -
  • - {{ 'List Rights'|trans }} -
  • diff --git a/rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateTranslateToTwigRector/CakePHPTemplateTranslateToTwigRectorTest.php b/rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateTranslateToTwigRector/CakePHPTemplateTranslateToTwigRectorTest.php deleted file mode 100644 index 1bd3c51f8d03..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateTranslateToTwigRector/CakePHPTemplateTranslateToTwigRectorTest.php +++ /dev/null @@ -1,30 +0,0 @@ -doTestFileWithoutAutoload($file); - } - - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return CakePHPTemplateTranslateToTwigRector::class; - } -} diff --git a/rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateTranslateToTwigRector/Fixture/fixture.php.inc b/rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateTranslateToTwigRector/Fixture/fixture.php.inc deleted file mode 100644 index abb994b1bcc4..000000000000 --- a/rules/cakephp-to-symfony/tests/Rector/Echo_/CakePHPTemplateTranslateToTwigRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,3 +0,0 @@ -

    ------ -

    {{ 'Actions'|trans }}

    diff --git a/src/PhpParser/Node/Manipulator/ClassManipulator.php b/src/PhpParser/Node/Manipulator/ClassManipulator.php index f5b7aef55c87..18efae4034b6 100644 --- a/src/PhpParser/Node/Manipulator/ClassManipulator.php +++ b/src/PhpParser/Node/Manipulator/ClassManipulator.php @@ -5,7 +5,6 @@ namespace Rector\Core\PhpParser\Node\Manipulator; use PhpParser\Node; -use PhpParser\Node\Identifier; use PhpParser\Node\Name; use PhpParser\Node\Name\FullyQualified; use PhpParser\Node\Stmt\Class_; @@ -36,11 +35,6 @@ final class ClassManipulator */ private $nodeTypeResolver; - /** - * @var PropertyFetchManipulator - */ - private $propertyFetchManipulator; - /** * @var NodesToRemoveCollector */ @@ -50,13 +44,11 @@ public function __construct( NodeNameResolver $nodeNameResolver, CallableNodeTraverser $callableNodeTraverser, NodesToRemoveCollector $nodesToRemoveCollector, - NodeTypeResolver $nodeTypeResolver, - PropertyFetchManipulator $propertyFetchManipulator + NodeTypeResolver $nodeTypeResolver ) { $this->nodeNameResolver = $nodeNameResolver; $this->callableNodeTraverser = $callableNodeTraverser; $this->nodeTypeResolver = $nodeTypeResolver; - $this->propertyFetchManipulator = $propertyFetchManipulator; $this->nodesToRemoveCollector = $nodesToRemoveCollector; } @@ -230,30 +222,6 @@ public function removeInterface(Class_ $class, string $desiredInterface): void } } - /** - * @param string[] $oldToNewPropertyNames - */ - public function renamePropertyFetches(Class_ $class, array $oldToNewPropertyNames): void - { - $this->callableNodeTraverser->traverseNodesWithCallable($class, function (Node $node) use ( - $oldToNewPropertyNames - ) { - if (! $this->propertyFetchManipulator->isLocalPropertyFetch($node)) { - return null; - } - - foreach ($oldToNewPropertyNames as $oldPropertyName => $newPropertyName) { - if (! $this->nodeNameResolver->isName($node->name, $oldPropertyName)) { - continue; - } - - $node->name = new Identifier($newPropertyName); - } - - return null; - }); - } - /** * @param string[] $propertyNames */ diff --git a/src/PhpParser/Node/Manipulator/PropertyFetchManipulator.php b/src/PhpParser/Node/Manipulator/PropertyFetchManipulator.php index cbf5953bf7f3..e17d1ab2286e 100644 --- a/src/PhpParser/Node/Manipulator/PropertyFetchManipulator.php +++ b/src/PhpParser/Node/Manipulator/PropertyFetchManipulator.php @@ -140,26 +140,6 @@ public function isLocalPropertyFetch(Node $node): bool return $this->nodeNameResolver->isName($node->var, 'this'); } - /** - * Matches: - * "$this->someValue = $;" - */ - public function isToThisPropertyFetchOfSpecificNameAssign(Node $node, string $propertyName): bool - { - if (! $node instanceof Assign) { - return false; - } - - if (! $this->isLocalPropertyFetch($node->var)) { - return false; - } - - /** @var PropertyFetch $propertyFetch */ - $propertyFetch = $node->var; - - return $this->nodeNameResolver->isName($propertyFetch->name, $propertyName); - } - private function hasPublicProperty(PropertyFetch $propertyFetch, string $propertyName): bool { $nodeScope = $propertyFetch->getAttribute(AttributeKey::SCOPE);