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
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php