Skip to content

Commit 08e485a

Browse files
committed
update_to_5.0.md: Continue Rector exploration
1 parent 8cec138 commit 08e485a

File tree

1 file changed

+36
-15
lines changed

1 file changed

+36
-15
lines changed

docs/update_and_migration/from_4.6/update_to_5.0.md

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,43 @@ It supports only PHP 8.3 and above.
2525

2626
### Update custom code for PHP 8.3+ and DXP 4.6
2727

28-
If your DXP 4.6 is running on a PHP below 8.3, start migrating it to PHP 8.3.
28+
Rector helps to upgrade your code.
2929

30-
//TODO: Update composer.json require.php to help Rector find out the right PHP version your project is using
30+
Install [`ibexa/rector`](https://github.com/ibexa/rector) which contains rules to ensure custom code is up to date with DXP 4.6:
3131

32-
//IbexaSetList::IBEXA_46->value is only about Ibexa, add some PHP rule set
33-
34-
Use Ibexa Rector to help yourself to upgrade PHP code for 8.3,
35-
see [`ibexa/rector`'s README](https://github.com/ibexa/rector?tab=readme-ov-file#ibexa-dxp-rector)
36-
and [Rector's documentation](https://getrector.com/documentation)
37-
for more information about installation and usage.
38-
TODO: For example, you might have to remove the inclusion of `tests/ directory.
32+
```bash
33+
composer require --dev ibexa/rector
34+
```
3935

40-
Rector might also find out code deprecated in 4.6 which are likely removed in 5.0.
41-
Let Rector reduce this debt and have less code not compatible with 5.0.
36+
Customize the `rector.php` config file.
37+
Make is match your directory structure (for example, you may have to remove the `tests` directory).
38+
You can add rules [for PHP with `withPhpSets`](https://getrector.com/documentation/set-lists#content-php-sets)
39+
or [for Symfony with `withComposerBased`](https://getrector.com/blog/introducing-composer-version-based-sets).
40+
It's recommended to activate one rule set at a time, run a first time with the `--dry-run` option,
41+
check the output, and decide if kept right now, or discarded for another time.
42+
TODO: Can it be kept for another time or will it break?
43+
Your configuration could look like the following:
4244

43-
TODO: Example with our own code samples?
44-
TODO: list of features deprecated in 4.6 removed in 5.0?
45+
```php
46+
return RectorConfig::configure()
47+
->withPaths(
48+
[
49+
__DIR__ . '/src',
50+
]
51+
)
52+
->withSets(
53+
[
54+
IbexaSetList::IBEXA_46->value,
55+
]
56+
)
57+
->withPhpSets(php83: true)
58+
->withComposerBased(symfony: true)
59+
;
60+
```
4561

46-
### TODO: Other updates like moving from any deprecated stuff?
62+
```bash
63+
php vendor/bin/rector --dry-run
64+
```
4765

4866
### TODO: Install all 4.6 LTS Updates? It could help with the DB schemas or configs…
4967

@@ -355,6 +373,8 @@ php bin/console ibexa:graphql:generate-schema
355373

356374
#### Update PHP framework standards
357375

376+
TODO: Merge up / deduplicate with DXP 4.6 / Symfony 5.4 usage of Rector above…
377+
358378
Update the `rector.php` file to use `IbexaSetList::IBEXA_50` rule set.
359379
If you didn't edit it the first time, you can run its recipe:
360380

@@ -364,7 +384,7 @@ composer recipe:install ibexa/rector --force --reset --yes
364384

365385
You can add some other rule sets (like, for example, the Symfony ones) to match newer standards.
366386

367-
It's recommended to activate one set at a time, run a first time with the `--dry-run` option,
387+
Again, it's recommended to activate one set at a time, run a first time with the `--dry-run` option,
368388
check the output, and decide if kept right now, or discarded for another time.
369389

370390
```php
@@ -375,6 +395,7 @@ use Rector\Symfony\Set\SensiolabsSetList;
375395
->withSets(
376396
[
377397
IbexaSetList::IBEXA_50->value,
398+
SymfonySetList::SYMFONY_54, // https://getrector.com/find-rule?activeRectorSetGroup=symfony&rectorSet=symfony-symfonysymfony-54
378399
SymfonySetList::SYMFONY_60, // https://getrector.com/find-rule?activeRectorSetGroup=symfony&rectorSet=symfony-symfonysymfony-60
379400
SymfonySetList::SYMFONY_61, // https://getrector.com/find-rule?activeRectorSetGroup=symfony&rectorSet=symfony-symfonysymfony-61
380401
SymfonySetList::SYMFONY_62, // https://getrector.com/find-rule?activeRectorSetGroup=symfony&rectorSet=symfony-symfonysymfony-62

0 commit comments

Comments
 (0)