On 28/12/2020 20:21, Larry Garfield wrote:
After considerable discussion and effort, Ilija and I are ready to offer you
round 2 on enumerations.
Thank you both, again, for all your efforts. I'm pleased to say that I
like this draft even more than the last one. :)
A couple of points that occurred to me reading through:
- The magic methods section lists __call as allowed, but not
__callStatic; was this deliberate, or just an oversight?
- Under Future Scope, the "Grouped Syntax" sub-section says "That would
only work on the simple, non-primitive-backed case with no methods
defined [...] it is unclear how common that will be in practice" This
caveat doesn't apply to the current proposed syntax, and should perhaps
be re-visited.
Given that this is currently a legal declaration:
class Suit {
const Hearts = 'H', Diamonds = 'D', Clubs = 'C', Spades = 'S';
}
It seems fairly reasonable for the enum version to allow the same syntax:
enum Suit: string {
case Hearts = 'H', Diamonds = 'D', Clubs = 'C', Spades = 'S';
}
Or, for a non-scalar enum:
enum Suit {
case Hearts, Diamonds, Clubs, Spades;
}
Regards,
--
Rowan Tommins
[IMSoP]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php