# [RFC] [Discussion] Debugable enums

- Thread: https://externals.io/message/130303
- Original archive: https://news-web.php.net/php.internals/130303
- Started by Daniel Scherzer on 2026-03-13T00:05:53+00:00
- Messages: 6
- RFC: Debugable Enums (Implemented (PHP 8.6)) — https://externals.io/rfc/debugable-enums.md
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #130303 — Daniel Scherzer — 2026-03-13T00:05:53+00:00

URL: https://externals.io/message/130303#130303

Hi internals,

I'd like to start the discussion for a new RFC about removing the
prohibition on __debugInfo() methods on enums.

* RFC: https://wiki.php.net/rfc/debugable-enums
* Implementation: https://github.com/php/php-src/pull/21425

This is a replacement of my earlier RFC to allow __toString() based on the
feedback in that discussion, see
https://news-web.php.net/php.internals/129540.

Thanks,
-Daniel

---

## #130308 — Larry Garfield — 2026-03-13T14:54:18+00:00

URL: https://externals.io/message/130303#130308 · In reply to: #130303

> Hi internals,
>
> I'd like to start the discussion for a new RFC about removing the 
> prohibition on __debugInfo() methods on enums.
>
> * RFC: https://wiki.php.net/rfc/debugable-enums
> * Implementation: https://github.com/php/php-src/pull/21425
>
> This is a replacement of my earlier RFC to allow __toString() based on 
> the feedback in that discussion, see 
> https://news-web.php.net/php.internals/129540.
>
> Thanks,
> -Daniel

I'm not entirely sure this has much value, but it also seems to not have much downside.  The main argument I could see for holding off is that whenever it is we get to ADTs, we may want a more complex default implementation.  But that would still presumably allow being overridden, like any other class, so it doesn't seem like a landmine to me.  This doesn't have the same semantic issues that __toString() has (and have been discussed elsewhere).

--Larry Garfield

---

## #130310 — Ilija Tovilo — 2026-03-13T19:42:43+00:00

URL: https://externals.io/message/130303#130310 · In reply to: #130303

Hi Daniel

On Fri, Mar 13, 2026 at 1:06 AM Daniel Scherzer
<daniel.e.scherzer@gmail.com> wrote:
>
> I'd like to start the discussion for a new RFC about removing the prohibition on __debugInfo() methods on enums.
>
> * RFC: https://wiki.php.net/rfc/debugable-enums
> * Implementation: https://github.com/php/php-src/pull/21425

The RFC currently only mentions:

> var_dump(Foo::Bar); // produces an array with "Bar is a case of the Foo enum"

But it would be good for it to spell out the full output for the
examples. From the implementation, I can see:

> object(Foo)#%d (1) {
>  [0]=>
>  string(14) "Foo::Bar = Baz"
> }

I think the enum(Foo::Bar) header should be preserved. If the user
wants to print some ancillary data for some reason, I wouldn't object
to that.

Ilija

---

## #130359 — Daniel Scherzer — 2026-03-15T18:04:25+00:00

URL: https://externals.io/message/130303#130359 · In reply to: #130310

On Sun, Mar 15, 2026 at 11:01 AM Ilija Tovilo <tovilo.ilija@gmail.com>
wrote:

> Hi Daniel
>
> On Fri, Mar 13, 2026 at 1:06 AM Daniel Scherzer
> <daniel.e.scherzer@gmail.com> wrote:
> > […]
> prohibition on __debugInfo() methods on enums.
> > […]
>
> The RFC currently only mentions:
>
> > […]
> enum"
>
> But it would be good for it to spell out the full output for the
> examples.
>

Done, examples now show the full output


> From the implementation, I can see:
>
> > […]
>
> I think the enum(Foo::Bar) header should be preserved. If the user
> wants to print some ancillary data for some reason, I wouldn't object
> to that.
>

Done, the header is now preserved. I also removed the object handler
identifier, which I don't think is as needed with enums.

Based on my understanding of the RFC policy (
https://github.com/php/policies/blob/main/feature-proposals.rst), this
qualifies as a major change, so there is now a cooldown period of 14 days
before the earliest that a vote could start.

-Daniel

---

## #130372 — tim@bastelstu.be — 2026-03-16T18:11:51+00:00

URL: https://externals.io/message/130303#130372 · In reply to: #130303

Hi

Am 2026-03-13 01:05, schrieb Daniel Scherzer:
> * RFC: https://wiki.php.net/rfc/debugable-enums
> * Implementation: https://github.com/php/php-src/pull/21425

Thank you. Similarly to Larry, I don't see much reason in favor, but 
also no reason against allowing `__debugInfo()`.

I noticed that the title of the voting widget did not render properly 
(it showed “Default title”). It seems the `<php>` tags were at fault. I 
have removed the tags and also added a “Primary Vote requiring a 2/3 
majority to accept the RFC:” note as required by policy and shown in the 
template.

Best regards
Tim Düsterhus

---

## #130504 — Daniel Scherzer — 2026-03-30T23:11:33+00:00

URL: https://externals.io/message/130303#130504 · In reply to: #130303

On Thu, Mar 12, 2026 at 5:05 PM Daniel Scherzer <daniel.e.scherzer@gmail.com>
wrote:

> Hi internals,
>
> I'd like to start the discussion for a new RFC about removing the
> prohibition on __debugInfo() methods on enums.
>
> * RFC: https://wiki.php.net/rfc/debugable-enums
> * Implementation: https://github.com/php/php-src/pull/21425
>
> This is a replacement of my earlier RFC to allow __toString() based on the
> feedback in that discussion, see
> https://news-web.php.net/php.internals/129540.
>


This email is a notice that I intend to open the vote on this RFC in the
next few days, barring any unexpected developments.

-Daniel
