On Sun, Apr 23, 2023 at 1:57 PM Lokrain <[email protected]> wrote:
>
> Hello,
>
> For me, this is just a wrong way of using enums for the sake of opinionated
> solution of specific problem.
>
> Regards,
> Dimitar
>
> On Sun, 23 Apr 2023 at 14:23, Niels Dossche <[email protected]> wrote:
>
> > Hi
> >
> > On 4/19/23 17:11, Garet Claborn wrote:
> > > Hello PHP Internals,
> > >
> > > I am Garet Claborn, CTO for Suitespace Inc
> > > <https://www.getsuiteux.com/>, leading
> > > up our R&D team. Just registered and my PHP Wiki username is:
> > > *suitespacernd*
> > >
> > > We use PHP extensively in our projects. Specifically I finally registered
> > > as I have written up an RFC in response to this issue thread
> > > <https://github.com/php/php-src/issues/9208> on GitHub. While I am
> > notably
> > > attached to said issue, I hope to provide useful feedback in general from
> > > our case studies.
> > >
> > > Feel free to reach out for whatever reason.
> > >
> > > Cheers,
> > > Garet Claborn
> > >
> > > CTO, Suitespace Inc
> > > [email protected]
> > >
> >
> > Good luck with the RFC, I'm also quite interested in this feature so I'm
> > interested to see where it goes.
> > You might also want to explicitly ask for RFC karma so that you can create
> > a wiki page for the RFC, if you haven't done that already :)
> >
> > Kind regards
> > Niels
> >
> > --
> > PHP Internals - PHP Runtime Development Mailing List
> > To unsubscribe, visit: https://www.php.net/unsub.php
> >
> >
> For me, this is just a wrong way of using enums for the sake of opinionated
> solution of specific problem.
That seems a bit of a strong reaction, though I agree that this can be
solved fairly easily in user-land:
trait ArrayKey {
public function key(): string {
return get_class($this) . '::' . $this->name;
}
}
enum T { use ArrayKey; case A; case B; }
echo T::A->key();
// outputs: T::A
or even set it up in the constructor.
If you don't have control over the enums, you can write a simple
function to the same. As a side-note, I would rather have enums able
to be casted to a string than to change how arrays work. Even if it
has to be something 'ugly' to keep people from using that itself as a
value (similar to how js symbol types work -- a one-way cast).
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php