On Mon, Dec 28, 2020, at 2:21 PM, Larry Garfield wrote:
> Hello, Internalians!
> 
> After considerable discussion and effort, Ilija and I are ready to 
> offer you round 2 on enumerations.  This is in the spirit of the 
> previous discussion, but based on that discussion a great deal has been 
> reworked.  The main change is that Enumeration Cases are now object 
> instances of the Enumeration class rather than their own class.  Most 
> of the other changes are knock-on effects of that.
> 
> Of particular note:
> 
> * Cases may not have methods or constants on them.  They're just dumb values.
> * Enums themselves may have methods, static methods, or constants.
> * Traits are supported, as long as they don't have properties.
> * The value() method on scalar enums is now a property.
> 
> The full RFC is here, and I recommend reading it again in full given 
> how much was updated.
> 
> https://wiki.php.net/rfc/enumerations
> 
> The implementation is 98% complete; there's still a few lagging bits in 
> reflection, and some opcache bugs that Ilija is still stomping on.
> 
> There are a few outstanding questions listed that we would like 
> feedback on.  We're not entirely certain which direction to go with 
> them, for reasons explained in the RFC.  Input on those is especially 
> welcome.
> 
> Happy New Year.  May it be enumerable.

For those who would like to play the home game but haven't been able to, Tyson 
Andre has build a delightful Wasm version of the enums branch so you can run 
actual code using enums.

https://tysonandre.github.io/php-rfc-demo/enums/

100% credit to Tyson for putting that together.  It's quite slick. :-)  (It's a 
few commits behind but nothing that should impact most testing; just some edge 
formatting around print_r, reflection, and stuff like that.)

Also, while we were at it, we went with the from()/tryFrom() method pair.  No 
one seemed morally opposed to them and there wasn't really a better naming 
convention.

Aside from some nitpicking around reflection and possibly fiddling with the 
naming of "Scalar Enum" et al, we're closing in on the final version.  It will 
probably go to a vote in the not too distant future.

--Larry Garfield

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

Reply via email to