Re: RFC proposal: values getter in BackedEnum

From: Date: Thu, 09 Feb 2023 16:47:35 +0000
Subject: Re: RFC proposal: values getter in BackedEnum
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-119512@lists.php.net to get a copy of this message
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 apply to any array or object than having to learn about a new convenience method that is a few characters shorter, but entirely specific to enums. It also raises the question why your proposal only includes BackedEnum::values() instead of also including UnitEnum::names()? I find that I seldomly have the need for backed enums in the first place. The name is sufficient to uniquely identify the case and it's also the value that is used when serialize()ing an enum. Best regards Tim Düsterhus PS: I appreciate that you follow the "no top post" rule, however I find it hard to identify the end of the quoted text and the beginning of your reply, because there is no clear separator or indicator. It also appears to break the externals.io parser [1], which is unfortunate. Is it possible for you to configure your email client to use a quote format that includes the standard '> ' prefix in quoted lines? [1] https://externals.io/message/119499#119511

« previous php.internals (#119512) next »