Re: [RFC] [Discussion] Add values() Method to BackedEnum
| From: | Alexandru Pătrănescu | Date: | Tue, 11 Nov 2025 11:43:37 +0000 |
| Subject: | Re: [RFC] [Discussion] Add values() Method to BackedEnum | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-129197@lists.php.net to get a copy of this message | ||
On Tue, Nov 11, 2025 at 10:29 AM Mikhail Savin <mikhail.d.savin@gmail.com>
wrote:
>
> That said, adding values() to BackedEnum is a source-level BC break for
> codebases that already define conflicting values() on backed enums.
>
> But, as we can see from GitHub searches that I posted in PR, most of the
> implementations is exactly the same, so BC break is very small
>
Do you think you can quantify this BC break: how many implementations are
having a different signature? And update the RFC "Impact on Ecosystem"
section?
Small note:
implementations usually use
array_column(self::cases(), 'value') instead
of array_map(static fn(self $c) => $c->value, self::cases()).
and that's just normal, as it is 2x faster: https://3v4l.org/Q5AYg#v8.4.14
maybe mention it as well, or instead of the one you had it the examples, as
this is usually how it can be found in libraries.
--
Alex