rectorphp / rector-doctrine

Rector upgrade rules for Doctrine
https://getrector.com/find-rule?activeRectorSetGroup=doctrine
MIT License
57 stars 56 forks source link

Refactor the OrderByKeyToClassConstRector to use the new enum only in `Criteria::orderBy` method calls #336

Closed julienfastre closed 1 month ago

julienfastre commented 2 months ago

Since version 2.2.0 of doctrine/collection, the constant Doctrine\Common\Collections\Criteria is deprecated in favor of new enum \Doctrine\Common\Collections\Order.

But this enum should only be used in invocations of Doctrine\Common\Collection\Criteria::orderBy method call. Other calls (in attributes, or for the same method name on object instantiating another class) should not be changed: the string 'ASC' and 'DESC' should be kept elsewhere.

This PR refactor the rule which, previously, replaced all the 'ASC' and 'DESC' by the Criteria::ASC|DESC.

After this MR:

The previous rule, which changed the usage of the string "ASC" (lowercase or uppercase) or "DESC" (lowercase or uppercase) by the usage of Criteria::ASC and Criteria::DESC is, obviously, removed.

Comments and documentation supporting this change

Closes https://github.com/rectorphp/rector-doctrine/issues/325

EDIT list the changes in a more understandable (?) way.

julienfastre commented 2 months ago

Still some TODO in this PR:

samsonasik commented 1 month ago

Thank you @julienfastre

TomasVotruba commented 1 month ago

Thank you @julienfastre :+1: