Skip to content

[RFC] Allow __toString() on enums#20415

Closed
DanielEScherzer wants to merge 1 commit intophp:masterfrom
DanielEScherzer:stringable-enums
Closed

[RFC] Allow __toString() on enums#20415
DanielEScherzer wants to merge 1 commit intophp:masterfrom
DanielEScherzer:stringable-enums

Conversation

@DanielEScherzer
Copy link
Member

@iluuu1994
Copy link
Member

In case you aren't aware of the previous proposal: https://wiki.php.net/rfc/auto-implement_stringable_for_string_backed_enums The feedback was mixed, and the proposal was eventually withdrawn. Ofc, the two proposals aren't equivalent but I suspect a lot of the feedback will be the same.

@stepo2
Copy link

stepo2 commented Dec 4, 2025

The RFC and the provided test cases in this PR only cover unbacked and string-backed enums that implement __toString() in some way. What I am missing is 1) the future behaviour of enums (backed or not) without the __toString() method (especially string-backed ones) and 2) the behaviour of int-backed enums implementing the __toString() method. I assume they would behave unchanged or equivalent, but for the sake of completeness and ruling out every possible doubt this should be covered in RFC and tests.

@DanielEScherzer
Copy link
Member Author

Replaced with #21425 based on mailing list feedback

@DanielEScherzer DanielEScherzer deleted the stringable-enums branch March 13, 2026 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants