Re: [RFC] Enumerations, Round 2

From: Date: Wed, 30 Dec 2020 16:07:34 +0000
Subject: Re: [RFC] Enumerations, Round 2
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-112665@lists.php.net to get a copy of this message
On Wed, Dec 30, 2020, at 2:43 AM, Markus Fischer wrote: > Hi, > > On 28.12.20 21:21, Larry Garfield wrote: > > The full RFC is here, and I recommend reading it again in full given how much was updated. > > > > https://wiki.php.net/rfc/enumerations > > I tried to answer the following question but failed to do so: > > What is the scalar value for a ScalarEnum if none is explicitly defined? > > The RFC makes this example: > > enum Suit: string implements Colorful { > > case Hearts = 'H'; > > case Diamonds = 'D'; > … > > 'D' == Suit::Diamonds->value; // true > > > What in this case? > > > enum Suit: string { > > case Hearts; > > case Diamonds; > … > > What is the outcome of Suit::Diamonds->value ? A parse error on the declaration; if it's a scalar enum, explicit values are required for all cases. --Larry Garfield

« previous php.internals (#112665) next »