Skip to content

Conversation

@dlubitz
Copy link
Contributor

@dlubitz dlubitz commented Jul 25, 2025

Compatibility with PHPRector 2.x

This PR makes the neos/rector package compatible with rector/rector version 2.x.

For more context, please also see: neos/neos-development-collection#5607

PHP compatibility
The migrations are now compatible with PHP 8.x incl. PHP 8.4. The test suite of this package requires PHP 8.2 at minimum due to PHPUnit in v12.

PHP-only migrations
Due to the fact, rector/rector removed the possibility to add custom file handlers, to focus on PHP refactoring, we had to remove the Fusion and YAML migrations from this package. They have been moved into Neos core migrations.

See:

Improved setup
Using the outdated version of rector/rector resulted in conflicting dependency constraints with Neos 9 dependencies. This meant that neos/rector had to be installed separately alongside the Neos project. This issue is now resolved, and neos/rector can simply be installed as a dev dependency in any Neos 9 project.

# inside your Distribution folder
composer require --dev neos/rector:dev-main
cp Packages/Libraries/neos/rector/rector.template.php rector.php

Things to know

  • Why so many changes:
    Most changes became necessary because a convenience method to add nodes before a given node
    (nodesToAddCollector->addNodesBeforeNode()) has been removed. Since neos/rector heavily relied on this,
    most rules had to be rewritten. To achieve the same behavior as before, the rules now apply on a higher level
    (mostly statements), making it possible to insert additional statements beforehand.

  • Test-driven refactoring:
    I tried to modify the test cases as little as possible while refactoring the rules. In some cases, I had to
    add or remove empty lines around comments, as the handling of comments has changed.

@dlubitz dlubitz changed the title Upgrade 2.x WIP Upgrade package to rector/rector 2.x Jul 25, 2025
dlubitz added 24 commits October 9, 2025 22:21
@dlubitz dlubitz marked this pull request as ready for review November 22, 2025 14:54
@dlubitz dlubitz changed the title WIP Upgrade package to rector/rector 2.x Upgrade package to rector/rector 2.x Nov 22, 2025
Copy link
Member

@kdambekalns kdambekalns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all: Thanks for tackling that massive task!

Now, I looked a quite a few of these files…

  • the configured_rule.php files all have wrong indetation from the changes done to them, I gave up suggesting a change after a while 😇
  • left a comment on some commented block of code – can't that go away completely?

The files I looked at seem to follow a reasonable "change pattern", so here we go with a "👍 by 🫣" under the assumption my remarks get adressed.

Copy link
Member

@kdambekalns kdambekalns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still 👍 by 👀

@mhsdesign
Copy link
Member

Thanks for all the work and not giving up!!!!

@mhsdesign mhsdesign merged commit 772ba7b into main Dec 12, 2025
2 checks passed
@mhsdesign mhsdesign deleted the upgrade-2.x branch December 12, 2025 15:50
@dlubitz dlubitz mentioned this pull request Dec 12, 2025
@simonschaufi
Copy link

simonschaufi commented Dec 12, 2025

I want to make you aware that TYPO3 had the same problem and we now have a new tool called Fractor for all other file types: https://github.com/andreaswolf/fractor/

If you want to migrate fusion, you can create your own fusion file processor as a standalone composer package and load that into fractor. Yaml is already supported.

@dlubitz
Copy link
Contributor Author

dlubitz commented Dec 12, 2025

Thank you @simonschaufi for the hint. If we had known this some time earlier 🙈

@simonschaufi
Copy link

simonschaufi commented Dec 12, 2025

I was aware of neos/rector but I wasn't aware that you also migrate fusion with it as I'm not aware of Neos development in general. I just read about it in the announcements channel in slack. If you are interested and want to have a small presentation of Fractor, we can have a video call.

@dlubitz
Copy link
Contributor Author

dlubitz commented Dec 12, 2025

We even didn't consider to check if there is already a solution. We only discussed to implement a "similar" solution to Fractor on our own. But we rejected this very quickly.

Thank you for the offer, I already had a look. Looks promising. I'll bring this discussion into our next developer meeting and will come back to you.

@simonschaufi
Copy link

The way how it works is almost identical like Rector and I also try to make the config and cli params as identical as possible to rector.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants