On 28.12.2020 21:21, Larry Garfield wrote:
> https://wiki.php.net/rfc/enumerations
Why can't this be simplified to:
enum Size {
case Small;
case Medium;
case Large;
}
'Small' === Size::Small->value; // true
Size::from('Small') === Size::Small; // true
enum Suit {
case Hearts = 'H';
case Diamonds = 'D';
case Clubs = 'C';
case Spades = 'S';
}
'H' === Suit::Hearts->value; // true
'Hearts' === Suit::Hearts->value; // false
Also, how about using a method instead of property for ->value?
--
Aleksander Machniak
Kolab Groupware Developer [https://kolab.org]
Roundcube Webmail Developer [https://roundcube.net]
----------------------------------------------------
PGP: 19359DC1 # Blog: https://kolabian.wordpress.com
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php