Skip to content

Commit ee9c444

Browse files
committed
[rector]: Update README
Old rector rules were removed. Linking to last version where they worked. Documented set NETTE_ANNOTATIONS_TO_ATTRIBUTES.
1 parent 091ce4f commit ee9c444

File tree

2 files changed

+60
-14
lines changed

2 files changed

+60
-14
lines changed

README.md

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ return static function (RectorConfig $rectorConfig): void {
5050

5151
// set with CRM 1.0 changes; check README for list of sets
5252
$rectorConfig->sets([
53-
CrmSetList::CRM_1_0,
53+
CrmSetList::CRM_3_0_PSR4,
54+
CrmSetList::NETTE_ANNOTATIONS_TO_ATTRIBUTES,
5455
]);
5556

5657
// set service if you want to run individual rule; check README for list of rules
@@ -77,25 +78,29 @@ _Use `vendor/bin/rector --help` for help. Notable flags are `-vvv` for verbose m
7778

7879
## Sets & rules
7980

80-
### Upgrade CRM v0.38 -> CRM v1.0
81+
### Transform Nette annotations to attributes
8182

82-
Check also the [CRM 1.0 migration guide](https://github.com/remp2020/crm-application-module/blob/master/MIGRATION.md).
83+
Set:
8384

84-
#### Sets
85+
```php
86+
$rectorConfig->sets([\Crm\Utils\Rector\Set\CrmSetList::NETTE_ANNOTATIONS_TO_ATTRIBUTES]);
87+
```
8588

86-
- Set: `Crm\Utils\Rector\Set\CrmSetList::CRM_1_0` contains CRM changes and Nette rules (3.0, 3.1).
87-
- Set: `Crm\Utils\Rector\Set\CrmSetList::CRM_1_0_WITHOUT_NETTE` contains only CRM changes.
88-
- You can call Nette sets from your `rector.php` later.
89-
- Set: `Crm\Utils\Rector\Set\CrmSetList::NETTE_ANNOTATIONS_TO_ATTRIBUTES` contains transformation of PHPdoc-based annotations to PHP 8.0 attributes (available since Nette 3.0+).
89+
Changes:
9090

91-
#### Individual rules
91+
```php
92+
/** @var @inject */
93+
public Crm\UsersModule\Repositories\UsersRepository $usersRepository;
94+
```
9295

93-
- [`\Crm\Utils\Rector\UpgradeToCrm1\ApiHandlerParametersRector`](src/UpgradeToCrm1/ApiHandlerParametersRector.php)
94-
- Changes parameters of Api handlers which implement interface `Crm\ApiModule\Api\ApiHandlerInterface` to CRM v1.0.
95-
- [`\Crm\Utils\Rector\UpgradeToCrm1\ApiHandlerJsonResponseRector`](src/UpgradeToCrm1/ApiHandlerJsonResponseRector.php)
96-
- Changes all instances of `Crm\ApiModule\Api\JsonResponse` to `Tomaj\NetteApi\Response\JsonApiResponse`.
96+
to:
9797

98-
_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._
98+
```php
99+
#[\Nette\DI\Attributes\Inject]
100+
public Crm\UsersModule\Repositories\UsersRepository $usersRepository;
101+
```
102+
103+
Fixes also `persistent` and `crossOrigin`.
99104

100105
### Transform to lazy event listeners
101106

@@ -115,3 +120,27 @@ _Note: Both these rules are part of sets `CRM_1_0` and `CRM_1_0_WITHOUT_NETTE`.
115120
CrmSetList::CRM_3_0_PSR4,
116121
]);
117122
```
123+
124+
---
125+
126+
### \[ARCHIVED\] Upgrade CRM v0.38 -> CRM v1.0
127+
128+
> ℹ️ 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.
129+
130+
Check also the [CRM 1.0 migration guide](https://github.com/remp2020/crm-application-module/blob/master/MIGRATION.md).
131+
132+
#### Sets
133+
134+
- Set: `Crm\Utils\Rector\Set\CrmSetList::CRM_1_0` contains CRM changes and Nette rules (3.0, 3.1).
135+
- Set: `Crm\Utils\Rector\Set\CrmSetList::CRM_1_0_WITHOUT_NETTE` contains only CRM changes.
136+
- You can call Nette sets from your `rector.php` later.
137+
- Set: `Crm\Utils\Rector\Set\CrmSetList::NETTE_ANNOTATIONS_TO_ATTRIBUTES` contains transformation of PHPdoc-based annotations to PHP 8.0 attributes (available since Nette 3.0+).
138+
139+
#### Individual rules
140+
141+
- [`\Crm\Utils\Rector\UpgradeToCrm1\ApiHandlerParametersRector`](src/UpgradeToCrm1/ApiHandlerParametersRector.php)
142+
- Changes parameters of Api handlers which implement interface `Crm\ApiModule\Api\ApiHandlerInterface` to CRM v1.0.
143+
- [`\Crm\Utils\Rector\UpgradeToCrm1\ApiHandlerJsonResponseRector`](src/UpgradeToCrm1/ApiHandlerJsonResponseRector.php)
144+
- Changes all instances of `Crm\ApiModule\Api\JsonResponse` to `Tomaj\NetteApi\Response\JsonApiResponse`.
145+
146+
_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._

src/Set/CrmSetList.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Crm\Utils\Rector\Set;
5+
6+
final class CrmSetList
7+
{
8+
/**
9+
* string
10+
*/
11+
public const NETTE_ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../config/sets/annotations-to-attributes.php';
12+
13+
/**
14+
* @var string
15+
*/
16+
public const CRM_3_0_PSR4 = __DIR__ . '/../../config/sets/crm-3-0-psr4.php';
17+
}

0 commit comments

Comments
 (0)