Re: [RFC] enum SortDirection

From: Date: Mon, 02 Mar 2026 22:14:58 +0000
Subject: Re: [RFC] enum SortDirection
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-130229@lists.php.net to get a copy of this message
On 2 March 2026 21:43:19 GMT, Bob Weinand <bobwei9@hotmail.com> wrote: >Hey Tim, > >On 2.3.2026 21:45:39, Tim Düsterhus wrote: >> Hi >> >> please consider this email as a formal request for comments on my modest proposal of adding >> a new enum SortDirection to PHP’s standard library. >> >> I have made the full proposal available on the World Wide Web at: >> >> https://wiki.php.net/rfc/sort_direction_enum >> >> Yours sincerely >> Tim Düsterhus > > >That's a good idea, but I wouldn't introduce such class without some usages at least. > >I'd recommend considering immediately upgrading the proposed functions to use SortDirection >and redefine the constants in terms of the enum. > >I.e. set const SORT_ASC = SortDirection::Ascending; - similar for others like the >SCANDIR_SORT_DESCENDING etc.. > >This is a reasonable BC break, which is also trivially fixed by simply accepting >int|SortDirection in existing functions. If its a BC break, it can't go into a 8.× for something that isn't *necessary*. But I also don't see how accepting both int and this new enum for existing built-in functions is a BC break. Changing the existing constants to something else is probably not a good idea, as other user functions or libraries might have reused them. cheers Derick

« previous php.internals (#130229) next »