rector-src icon indicating copy to clipboard operation
rector-src copied to clipboard

[Php84] Add rule for RoundingMode enum

Open jorgsowa opened this issue 1 year ago • 4 comments

Adds new rule for replacing mode constants in the function round() with RoundingMode cases in PHP 8.4.

The PR is not finished, but please let me know whether it makes sense to add such a rule to the PHP8.4 ruleset.

Referenced RFC: https://wiki.php.net/rfc/correctly_name_the_rounding_mode_and_make_it_an_enum

jorgsowa avatar Oct 09 '24 22:10 jorgsowa

Just a quick read, if I understand correctly, the constant is not deprecated (yet) in php 8.4, it just replaced in core code, so I think it is not really needed for now.

https://3v4l.org/Z40Kp/rfc#vgit.master

when on future, the constant will be deprecated, eg: on php 8.5, we can create the rule to migrate it, if this is accepted, we need to prepare immediatelly the Downgrade RoundingMode rules.

samsonasik avatar Oct 12 '24 16:10 samsonasik

It's unlikely that constants will be deprecated soon as it was the result of the RFC discussion. That's why I thought such a rule would help to speed up this process.

jorgsowa avatar Oct 13 '24 13:10 jorgsowa

I prefer to have downgrade rule instead first then, as replace constant is not required, but once it upgraded to enum, it needs to have downgrade rule to back to constant

https://github.com/rectorphp/rector-downgrade-php

samsonasik avatar Oct 13 '24 23:10 samsonasik

Makes sense. I will create a downgrade rule then.

jorgsowa avatar Oct 14 '24 06:10 jorgsowa

Thank you @jorgsowa

samsonasik avatar Dec 20 '24 00:12 samsonasik

This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work.

github-actions[bot] avatar Jan 11 '26 03:01 github-actions[bot]