Re: [PHP-DEV] RFC proposal: values getter in BackedEnum

2023-02-09 Thread Rowan Tommins
On Thu, 9 Feb 2023 at 16:18, Sergii Shymko wrote: > > IMO, other variations of array_column() returning a map don't seem to be > useful in practice. > Particularly, what is knowing the case name good for? Do you propose to > resolve it to the case instance like so? > $case =

Re: [PHP-DEV] RFC proposal: values getter in BackedEnum

2023-02-09 Thread Tim Düsterhus
Hi On 2/9/23 17:18, Sergii Shymko wrote: BackedEnum::values() is much more convenient than array_column(BackedEnum::cases(), 'value'); I suspect the answer is "preference", but I have to ask: Why? Personally looking at that I find it more convenient to use an existing function that I can

Re: [PHP-DEV] RFC proposal: values getter in BackedEnum

2023-02-09 Thread Sergii Shymko
From: Rowan Tommins Sent: Thursday, February 9, 2023 12:56 AM To: internals@lists.php.net Subject: Re: [PHP-DEV] RFC proposal: values getter in BackedEnum On Thu, 9 Feb 2023 at 01:30, Sergii Shymko wrote: > I'd like to propose an improvement to bac

Re: [PHP-DEV] RFC proposal: values getter in BackedEnum

2023-02-09 Thread Rowan Tommins
On Thu, 9 Feb 2023 at 01:30, Sergii Shymko wrote: > I'd like to propose an improvement to backed enumerations introduced in > PHP 8.1. > When using enums, it's very common to get all values using the following > boilerplate: > $enumValues = array_map( > fn (\BackedEnum $case) =>

Re: [PHP-DEV] RFC proposal: values getter in BackedEnum

2023-02-08 Thread Larry Garfield
On Wed, Feb 8, 2023, at 5:30 PM, Sergii Shymko wrote: > Hi, > > I'd like to propose an improvement to backed enumerations introduced in > PHP 8.1. > When using enums, it's very common to get all values using the > following boilerplate: > $enumValues = array_map( > fn (\BackedEnum $case) =>