cakephp / upgrade

Upgrade tools for CakePHP meant to facilitate migrating from one version of the framework to another
MIT License
110 stars 60 forks source link

add first version of chronos 3 rector #217

Closed LordSimal closed 1 year ago

LordSimal commented 1 year ago

This is a first proposal for how chronos 3 rectors rules can look like. The main part this currently adjust is the Fewer mutation methods mentioned in https://github.com/cakephp/chronos/blob/2.next/docs/en/2-4-upgrade-guide.rst

I added 2 separate rules for chronos3-date and chronos3-datetime since they need to be handled separately. But maybe I don't see a way how this can easily be combined into one ruleset so help is very much appreciated 😄

Also can someone tell my why chained method calls like

$dateTime->addWeek()->subWeek();

only get changed to this?

$dateTime->addWeeks(1)->subWeek();

As you can see in the failed tests bellow only the first method call gets refactored but not the following (or any additional chained methods)

Is this a bug in rector or is there a special setting we need to add to also apply those changes to chained method calls?


My main goal here is to get the base chronos class refactorings working so we only need to add our Cake\I18n\Date and Cake\I18n\DateTime classes to those respected rulesets.

LordSimal commented 1 year ago

I also don't really understand why we need a Makefile here...

LordSimal commented 1 year ago

maybe we should also make a separate 5.x branch for all the cake5 related rules...

LordSimal commented 1 year ago

I created a 5.x branch to justify the PHP8.1 requirement. But I will still try to remove the require-dev like mark story explained.

LordSimal commented 1 year ago

Anything else we can easily add for chronos related changes coming in Cake5?