Re: [RFC] [Under Discussion] Auto- implement Stringable for string backed enums

From: Date: Wed, 22 Jun 2022 13:05:31 +0000
Subject: Re: [RFC] [Under Discussion] Auto- implement Stringable for string backed enums
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-118046@lists.php.net to get a copy of this message
On 21 June 2022 23:47:15 BST, Nicolas Grekas <nicolas.grekas+php@gmail.com> wrote: >Hi everyone! > >I'd like to open a discussion on this RFC, to auto-implement Stringable for >string-backed enums: >https://wiki.php.net/rfc/auto-implement_stringable_for_string_backed_enums > >I'm looking forward to your feedback, I am not in favour of this RFC, especially because it is not opt-in. 1. Enums were introduced to add extra type safety. Allowing them to degrade to simple strings reduces that type safety. 2. It is not implemented for all enum types, only for string backed ones. This change would now make different classes of enums, without them being differently inherited classes. 3. The main use case seems to be to prevent having to type ->value, which would otherwise indicate reliably whether an enum is used as string argument. I won't be voting in favour of this RFC as it currently stands. cheers Derick

« previous php.internals (#118046) next »