It passed 22 to 2, with 2 abstaining, against the two-thirds majority it needed. Voting closed on April 1, 2026. It has been merged into php-src, with PHP 8.6 as the target.
enum SortDirection
Adds a global SortDirection enum with Ascending and Descending cases as a shared, type-safe way to express sort order.
Implement the SortDirection enum as outlined in the RFC?
This poll has closed.
Summary
PHP has no single, type-safe way to say "sort ascending" or "sort descending." This RFC from Tim Düsterhus adds a small built-in enum, SortDirection, that PHP itself, frameworks and your own code can all share.
The problem
Today there are many ways to express the same thing:
SORT_ASCandSORT_DESC, which only work witharray_multisort()SCANDIR_SORT_ASCENDINGandSCANDIR_SORT_DESCENDING, which only work withscandir()- Plain
'ASC'and'DESC'strings bool $ascendingflags- Separate functions, like
sort()andrsort()
Many frameworks and libraries end up defining their own type for this. Doctrine added its own Order enum only two years ago.
What it adds
The enum lives in the global namespace:
enum SortDirection { case Ascending; case Descending; }
You could use it in a query builder like this:
$query->orderBy('created_at', SortDirection::Descending);
It's a pure enum, so its cases have no string or int backing value. The RFC says there's no single correct value, since SQL, API query strings and other contexts each want something different. You can map it yourself with a match().
It's also straightforward to polyfill for older PHP versions. A library can accept the enum alongside its old string or int values using a union type. Later on, PHP's own functions, like scandir(), could accept it too, and that kind of change wouldn't need an RFC.
What it means for existing code
You can no longer declare your own SortDirection class or enum in the global namespace. A GitHub search found 178 results named SortDirection, counting both namespaced and global ones, and the namespaced ones are unaffected. The RFC notes that adding new global names isn't considered a break under PHP's policy.