Hi,

On 05.12.20 10:22, Pierre R. wrote:
I think that ::cases() should always return an array/iterable without keys, and let userland write their own code to create hashmaps with those when they need it. I think that having one case (non primitive cases) that doesn't yield string keys and the other (primitive cases) which holds string keys may create a confusion because behavior is different.

If behavior is different, this would mean you couldn't mix primitive and non primitive cases on the same enum, which, why not couldn't we do that?

I've no strong feelings and I think your idea makes sense.

But I would argue, of course without having hard facts, that the _majority_ will have the use-case for a 1:1, aka array with key => value, mapping.

Thus I would argue that having (considering your proposal being added) still such functionality would be useful for a very wide-audience without everyone having to reinvent a helper method to use the iterable.

thanks for considering,
- Markus

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to