On 30.12.20 12:00, Rowan Tommins wrote:
On 30 December 2020 08:43:33 GMT+00:00, Markus Fischer <mar...@fischer.name> 
wrote:
What is the scalar value for a ScalarEnum if none is explicitly
defined?

The question has no answer, because the declaration of the enum itself would be 
invalid:

If an enumeration is marked as having a scalar equivalent, then all cases must 
have a unique scalar equivalent defined explicitly.

enum Suit: string {
case Hearts;
case Diamonds;
}

Presumably, this would result in an Error being thrown when compiling the 
declaration.

I see.

What's the quickest way (=less code) to have an enum represent it's lexical name as the literal values?

So that `… case Foo; case Bar; …` results in `::Foo->value === 'Foo'` etc.?

Is this possible without implementing this manually for all cases?

thanks,
- Markus

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

Reply via email to