Make it easier to follow API changes in Rector #4222
-
Feature RequestThanks a lot for creating rector and making it opensource! I highly appreciate the what you do and I think this tool has a potential to change how the PHP ecosystem works. I would love to see the community growing around Rector and more and more rules being created, specifically to help upgrading certain framework and applications (like https://github.com/sabbelasichon/typo3-rector). However I see one major pain point, which makes writing and maintaining custom rules quite cumbersome and frustrating for me. Rector is evolving pretty quickly, and right it's hard to follow breaking changes in Rector API for everybody who develop custom rector rules rules in separate tools/repositories.
Possible solutions (and/or)A) Rector provides rectors for breaking changes ;) Maybe you already have a plan to address this issue somehow? Please don't get me wrong. I really appreciate the awesome support Thomas and other rector contributors are providing. Many times we've got direct help when trying to upgrade our library to newer Rector version. But the more external rector rules there are in the wild the more important it will be to have some upgrade helpers. |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments 3 replies
-
Hi Tym, thanks for thinking this through and thank you for opening this issues in such a nice way. Rector will go through more changes in the future, it's self-refactoring tool after all. In last 2 months we added completely new set called naming, that basically affect every PHP element that has a name that can be inferred. A class by type, a method by return type, a constant by value. I think we can expect more changes to come in the future. Most of these BC breaks can't be covered by Rector, or it would be very complicated one-time-use rule, that might skip some edge cases. I'm not sure keeping changelog or writing the "how to" will help. It will only describe lot of work in more explicit way. Symfony is doing great job at describing these BC breaks, yet in the scale it's lot of extra work, that only slowls down developers. Thus Rector was made to remove this problem. And it works. If you upgrade Symfony 2.x to 5.x, with Rector there is minimum reading of Symfony CHANGELOGs, unless something edgy happens. That's somethign I'd like to follow here to, as I'm very lazy, Rector users are super lazy and from this issue I feel I'm not the only one :). If we make a BC break, all the rules in Rector core are upgraded at once. It kind of does not make sense to develop Rector rules in slower paste, as they directly depend on Rector. What Could Work?Saying that, in the past had an idea of centralized rulesets. A ruleset for each package, that are direct part of Rector. First version of this idea you can see at Using single repository for rules brings these benefits:
Not a fantasy, but a reality:
Saying that, I'd cosinder moving rules to What do you think? |
Beta Was this translation helpful? Give feedback.
-
Hi, let me chime in as a mere user: I just got a symfony project that I need to update. The current version used is symfony 3.2. This is the other part of Tymeks request: integrating rules for frameworks is nice, I applaud to that, even if it might cause the rector to explode with rules from all over the place, that will be dealt with in due time. Please consider jumping to semver, and keep the dependencies and API stable within the major versions. |
Beta Was this translation helpful? Give feedback.
-
@maddy2101 In case of your symfony project I would not install rector in the project composer, but use rector in docker or use prefixed version of rector (so it doesn't conflict with project requirements) - see https://github.com/rectorphp/rector#install |
Beta Was this translation helpful? Give feedback.
-
well, that is a possibility, too. Thanks for the pointer. |
Beta Was this translation helpful? Give feedback.
-
@maddy2101 Hi Maddy, I wish you asked me earlier to save the trouble. There is prefixed Rector for that as @tmotyl said. Here: https://github.com/rectorphp/rector-prefixed I actually use the latest Rector Prefixed on upgrade of Symfony 2.8 app running on PHP 7.1, even without Docker. |
Beta Was this translation helpful? Give feedback.
-
don't bother, that happens when one does not read the ReadMe. My fault entirely. :) |
Beta Was this translation helpful? Give feedback.
-
Any follow up to this or shall we close it? |
Beta Was this translation helpful? Give feedback.
-
Converted to Discussion, that were introduced today on GitHub Universe. |
Beta Was this translation helpful? Give feedback.
-
I agree that you may want to consider following proper SEMVER for tagging the releases moving forward. I know that Rector is going so fast that soon you'll be in version 17 😂, but at least nobody will get a broken version. You could then encourage developers to use In my case, I'm using |
Beta Was this translation helpful? Give feedback.
-
We're following semver actually :) The 0.x follows different rules. The discussion is rather about how to keep all rules up to date, whereever they are. We can see composer-dependency approach fails, Symfony, Doctrine, Laravel ecosystem are lagging behind new version many months, sometimes years. The best way I see now is: #4222 (comment) |
Beta Was this translation helpful? Give feedback.
-
Good News 🥳I've got some good news on this topic 🙂 In Rector 0.10 we split community packages from core repository:
Now we experience similar problems like your package that use Rector first hand.
E.g. to upgrade to Rector 0.10, just run: vendor/bin/rector process src --config vendor/rector/rector/upgrade/rector_010.php |
Beta Was this translation helpful? Give feedback.
Hi Tym,
thanks for thinking this through and thank you for opening this issues in such a nice way.
Rector will go through more changes in the future, it's self-refactoring tool after all. In last 2 months we added completely new set called naming, that basically affect every PHP element that has a name that can be inferred. A class by type, a method by return type, a constant by value. I think we can expect more changes to come in the future.
Most of these BC breaks can't be covered by Rector, or it would be very complicated one-time-use rule, that might skip some edge cases.
I'm not sure keeping changelog or writing the "how to" will help. It will only describe lot of work in more explic…