You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
New rector to update Doctrine ORM QueryBuilder arguments to use SortDirection #9919
doctrine/orm 3.7 has deprecated the usage of strings in the second argument of \Doctrine\ORM\QueryBuilder::addOrderBy and \Doctrine\ORM\QueryBuilder::orderBy (asc or desc, case insensitive) in favor of the SortDirection enum of PHP.
A similar deprecation exists for \Doctrine\ORM\Query\Expr\OrderBy::__construct and \Doctrine\ORM\Query\Expr\OrderBy::add.
It would be great if Rector could migrate automatically the cases using literal values in calls.
Beware that the ORM QueryBuilder has done this change, but the DBAL QueryBuilder does not support SortDirection (which is also what makes it hard to migrate with a dumb search&replace instead of a rector)
Activity
stof commentedon Oct 1, 2026
Beware that the ORM QueryBuilder has done this change, but the DBAL QueryBuilder does not support SortDirection (which is also what makes it hard to migrate with a dumb search&replace instead of a rector)
TomasVotruba commentedon Oct 1, 2026
I think it's doable.
The
SortDirectionis some internal PHP class? If its from Doctrine, can you share PR it was added there?stof commentedon Oct 1, 2026
It is a new enum added in PHP 8.6, with
symfony/polyfill-php86providing it for older PHP versions (for PHP 8.1+).See doctrine/orm#11313 for the reference issue in the ORM (starting at doctrine/orm#11313 (comment) for the discussion part using the new PHP enum). Note that the first deprecated case (the
OrderBymapping attribute) is already covered by a rector added in rectorphp/rector-doctrine#525TomasVotruba commentedon Oct 6, 2026
Handled in rectorphp/rector-doctrine#530