Download the PHP package remp/crm-rector without Composer
On this page you can find all versions of the php package remp/crm-rector. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download remp/crm-rector
More information about remp/crm-rector
Files in remp/crm-rector
Package crm-rector
Short Description Rector rules for REMP/Crm
License MIT
Homepage https://remp2030.com
Informations about the package crm-rector
CRM - Rector rules
This repository contains Rector rules for upgrade of custom modules used with REMP CRM.
How to use
1. Install package
Note: Composer will ask if you trust plugin rector/extension-installer. This plugin installs CRM rules into Rector package.
2. Create rector.php:
Run command:
3. Update rector.php
Fill custom paths & options & sets/rules you want to run.
E.g. to update to CRM 1.0 it could look like this:
Sets and rules are listed below.
4. Run Rector:
After you reviewed planned changes, run it without --dry-run:
Use vendor/bin/rector --help for help. Notable flags are -vvv for verbose messages, --clear-cache and --xdebug if you need to debug rector rules.
Sets & rules
Upgrade CRM v3 to CRM v4
Set
Use set CrmSetList::CRM_4:
or individual subsets / rules.
Subsets
Replace deprecated BaseWidget and WidgetManager
This set (CrmSetList::CRM_4_LAZY_WIDGET_MANAGER) replaces deprecated classes BaseWidget and WidgetManager with BaseLazyWidget and LazyWidgetManager. They were deprecated since
version 2.1.0,
commit remp/crm-application-module@43d9c19f37
Replace PaymentsRepository and RecurrentPaymentsRepository constants with enums
This set (CrmSetList::CRM_4_ENUMS) handles renames of few enums where class name didn't contain context:
Crm\PaymentsModule\Models\ParsedMailLog\StateEnumrenamed toParsedMailLogStateEnum,Crm\PaymentsModule\Models\RecurrentPayment\StateEnumrenamed toRecurrentPaymentStateEnum,Crm\UsersModule\Models\AddressChangeRequest\StatusEnumrenamed toAddressChangeRequestStatusEnum.
And replaces all deprecated constants with enums:
PaymentsRepositoryconstants replaced byPaymentStatusEnumenums,RecurrentPaymentsRepositoryconstants replaced byRecurrentPaymentStateEnumenums,ParsedMailLogsRepositoryconstants replaced byParsedMailLogStateEnumenums,AddressChangeRequestsRepositoryconstants replaced byAddressChangeRequestStatusEnumenums.
Rules
Transform Crm\ApiModule\Models\Params\InputParam to specific *InputParam objects
This rule (\Crm\Utils\Rector\UpgradeToCrm4\InputParamChangeRector) changes \Crm\ApiModule\Models\Params\InputParam to specific InputParam object from tomaj/nette-api library.
See what will be changed in getRuleDefinition() method in \Crm\Utils\Rector\UpgradeToCrm4\InputParamChangeRector
Remove calls of deprecated methods from ParamsProcessor
This rule (\Crm\Utils\Rector\UpgradeToCrm4\RemoveParamsProcessorRector) will remove useless calls of ParamsProcessor. Some of these methods were removed (hasError()). And getErrors() or getValues() (loading API parameters from ParamsProcessor) are not needed anymore. API runner handles errors before loading handler and provides validated parameters to handle() method.
WARNING: This Rector rule does crude work. You still need to go through all changes and fix your API handlers (if you worked or need to work with errors).
If you use
ApiParamsValidatorInterface, do not run this Rector rule. It doesn't understand this context.
See what will be changed in getRuleDefinition() method in \Crm\Utils\Rector\UpgradeToCrm4\RemoveParamsProcessorRector
Transform Nette annotations to attributes
Set:
Changes:
to:
Fixes also persistent and crossOrigin.
Transform to lazy event listeners
Individual rules
\Crm\Utils\Rector\TransformToLazyEventListeners\TransformToLazyEventListeners- Changes register events method to new lazy variant and removes
$this->getInstance()call from all event registrations.
- Changes register events method to new lazy variant and removes
Upgrade CRM v2.* -> CRM v3.0
-
Set:
Crm\Utils\Rector\Set\CrmSetList::CRM_3_0_PSR4- contains namespace renames after class names / namespaces were changed to follow PSR4 standard.Usage:
[ARCHIVED] Upgrade CRM v0.38 -> CRM v1.0
ℹ️ We are not maintaining this set anymore. Set & rules were removed. Last release with working rules is https://github.com/remp2020/crm-rector/releases/tag/1.2.0.
Check also the CRM 1.0 migration guide.
Sets
- Set:
Crm\Utils\Rector\Set\CrmSetList::CRM_1_0contains CRM changes and Nette rules (3.0, 3.1). - Set:
Crm\Utils\Rector\Set\CrmSetList::CRM_1_0_WITHOUT_NETTEcontains only CRM changes.- You can call Nette sets from your
rector.phplater.
- You can call Nette sets from your
- Set:
Crm\Utils\Rector\Set\CrmSetList::NETTE_ANNOTATIONS_TO_ATTRIBUTEScontains transformation of PHPdoc-based annotations to PHP 8.0 attributes (available since Nette 3.0+).
Individual rules
\Crm\Utils\Rector\UpgradeToCrm1\ApiHandlerParametersRector- Changes parameters of Api handlers which implement interface
Crm\ApiModule\Api\ApiHandlerInterfaceto CRM v1.0.
- Changes parameters of Api handlers which implement interface
\Crm\Utils\Rector\UpgradeToCrm1\ApiHandlerJsonResponseRector- Changes all instances of
Crm\ApiModule\Api\JsonResponsetoTomaj\NetteApi\Response\JsonApiResponse.
- Changes all instances of
_Note: Both these rules are part of sets CRM_1_0 and CRM_1_0_WITHOUT_NETTE. These are created as individual rules because Rector's general rules were not sufficient. We recommend running whole set._