rector-doctrine
rector-doctrine copied to clipboard
Refactor the OrderByKeyToClassConstRector to use the new enum only in `Criteria::orderBy` method calls
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
. Now, the rule:
- check that the method call is on
Criteria::orderBy
(still todo) - and replace by the new enum (
Order
).
Comments and documentation supporting this change
- https://github.com/doctrine/collections/pull/389;
- https://github.com/doctrine/orm/issues/11313#issuecomment-2214570323
Closes https://github.com/rectorphp/rector-doctrine/issues/325