Skip to content

Commit 772ba7b

Browse files
authored
Merge pull request #147 from neos/upgrade-2.x
Upgrade package to rector/rector 2.x
2 parents e1260d9 + 0845891 commit 772ba7b

File tree

532 files changed

+4551
-18721
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

532 files changed

+4551
-18721
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
php-versions: ['8.2', '8.3']
18+
php-versions: ['8.3', '8.4']
1919

2020
runs-on: ubuntu-latest
2121

README.md

Lines changed: 20 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,26 @@
22

33
This package contains a Rector ruleset which is used for migrating from Neos 8.x to 9.0 (and lateron also further up).
44

5-
It will eventually replace Core/Code Migrations (./flow flow:core:migrate) (which are not used anymore for migrating to Neos 9 and further).
6-
75
Right now we focus especially on rules to migrate from the old Content Repository API (< Neos 9.0) to the
86
Event Sourced Content Repository (>= 9.0).
97

8+
**PHP-only migrations**
9+
10+
Earlier version of `neos/rector` also did the migration of Yaml and Fusion file. They have been moved into Neos core migrations starting version 9.0.8. Now `neos/rector` only contains PHP migrations.
11+
12+
See for more details: https://github.com/neos/neos-development-collection/issues/5607
13+
14+
15+
1016
## Installation
11-
As Rector has strict dependency requirements, which might not match your own project, we strongly recommend to install
12-
neos/rector in a dedicated directory and **not to add it to your project**.
17+
18+
Please install the neos/rector package in your Distribution as a dev dependency with composer.
19+
<br>(This has changed to previous versions of this package)
1320

1421
```bash
1522
# inside your Distribution folder
16-
composer create-project neos/rector:dev-main --stability=dev rector
17-
cp rector/rector.template.php rector.php
23+
composer require --dev neos/rector:dev-main
24+
cp Packages/Libraries/neos/rector/rector.template.php rector.php
1825
```
1926

2027
## Configuration
@@ -24,19 +31,12 @@ migrated). By default, all of `./DistributionPackages` will be migrated.
2431

2532
Right now, we ship the following sets of Rector rules:
2633

27-
- `\Neos\Rector\NeosRectorSets::CONTENTREPOSITORY_9_0`: all rules needed to migrate to the Event-Sourced Content Repository
28-
29-
Also you need to add the autoload paths, to allow rector to parse your code properly. By default we added `./Packages` and `./DistributionPackages` to the template.
34+
- `\Neos\Rector\NeosRectorSets::CONTENTREPOSITORY_9_0`: all rules needed to migrate to the Event-Sourced Content
35+
Repository
3036

3137
```php
3238
$rectorConfig->sets([
3339
NeosRectorSets::CONTENTREPOSITORY_9_0,
34-
//NeosRectorSets::NEOS_8_4,
35-
]);
36-
37-
$rectorConfig->autoloadPaths([
38-
__DIR__ . '/Packages',
39-
__DIR__ . '/DistributionPackages',
4040
]);
4141

4242
$rectorConfig->paths([
@@ -52,11 +52,12 @@ Run the following command at the root of your distribution (i.e. where `rector.p
5252

5353
```bash
5454
# for trying out what would be done
55-
./rector/vendor/bin/rector --dry-run
55+
./bin/rector --dry-run
5656

5757
# for running the migrations
58-
./rector/vendor/bin/rector
58+
./bin/rector
5959
```
60+
6061
---
6162

6263
# Developing Rector Rules for Neos
@@ -77,58 +78,13 @@ The test setup runs completely self contained; does not need *any* Distribution
7778

7879
```bash
7980
# if inside a Neos Distribution, change to the Package's folder
80-
cd rector
81+
cd Packages/Libraries/neos/rector
8182

8283
# install PHPunit
8384
composer install
8485

8586
# run PHPUnit
86-
composer test
87-
```
88-
89-
## Fusion Rector
90-
91-
We extended Rector specifically for migrating Fusion files, by providing a `FusionFileProcessor` and a `FusionRectorInterface`
92-
which you can implement if you want to build Fusion transformations.
93-
94-
The Fusion Rectors will usually use one of the following tooling classes:
95-
96-
- `EelExpressionTransformer`: for finding all Eel expressions inside Fusion and AFX; and transforming them in some way.
97-
98-
The Fusion and AFX Parsing functionality is based on the official Fusion and AFX parsers. However, the classes are
99-
vendored/copied into this package by the `./embed-fusion-and-afx-parsers.sh` script, because of the following reasons:
100-
101-
- Rector needs to run even when Flow cannot compile the classes; so we cannot depend on a Flow package.
102-
- We slightly need to patch the AFX parser, because we need position information for Eel Expressions.
103-
104-
The Fusion parser was subclassed by `Neos\Rector\Core\FusionProcessing\CustomObjectTreeParser` for retaining position
105-
information of AFX and Eel Expressions.
106-
107-
108-
**Updating Fusion and AFX Parser**
109-
110-
To update the vendored Fusion and AFX parsers, run the `./embed-fusion-and-afx-parsers.sh` script.
111-
112-
113-
**Updating the AFX Parser Patch**
114-
115-
The AFX parser needs a custom patch (see `./scripts/afx-eel-positions.patch`) to retain positions.
116-
117-
To create/update this patch, do the following:
118-
119-
```bash
120-
cd Packages/Neos
121-
122-
# apply the current patch
123-
patch -p1 < ../../rector/scripts/afx-eel-positions.patch
124-
125-
# Now, do your modifications as needed.
126-
127-
# when you are finished, create the new patch
128-
git diff -- Neos.Fusion.Afx/ > ../../rector/scripts/afx-eel-positions.patch
129-
130-
# ... and reset the code changes inside Neos.Fusion.Afx.
131-
git restore -- Neos.Fusion.Afx/
87+
composer tests
13288
```
13389

13490
## Generating docs

composer.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@
1616
"tests": "phpunit tests"
1717
},
1818
"require": {
19-
"php": "8.0.* || 8.1.* || 8.2.* || 8.3.*",
20-
"rector/rector": "0.15.25",
21-
"phpstan/phpstan": "1.10.14",
19+
"php": "^8.3",
20+
"rector/rector": "^2.0",
2221
"symfony/yaml": "*",
2322
"neos/utility-arrays": "*",
2423
"webmozart/assert": "^1.11"
2524
},
2625
"require-dev": {
27-
"phpunit/phpunit": "^9.5",
28-
"symplify/rule-doc-generator": "^11.1"
26+
"phpunit/phpunit": "^12.0",
27+
"symplify/rule-doc-generator": "^12.2"
2928
}
3029
}

0 commit comments

Comments
 (0)