Right, but enums could possibly be a lot richer than class constants are now.
They could be a type where the only values are what's defined in the enum. This could be used with type hinting: enum Foo { A, B, C } function bar(Foo $x) { // ... } There'd be no need to do any manual checking that $x is a valid value. Perhaps enum values could also be casted back to strings: (string)Foo::B; // "B" Sure, this is the kind of stuff that's possible in other ways already, but first class support always helps. On Feb 22, 2012 4:14 PM, "Laruence" <larue...@php.net> wrote: > On Wed, Feb 22, 2012 at 12:45 PM, Samuel Deal <samuel.d...@gmail.com> > wrote: > > Hi all, > > > > I really missed enums in PHP, > Why? we have class constant. > > thanks > > So after reading I tryed to synthetise the various views. > > > > You can find a draft here : > > https://github.com/SamNrique/php-src/wiki/RFC-draft > > (I can't write on the wiki, and perhaps it's better to finish the > > discussion first) > > > > There's an implementation with this draft. > > I'd love to have feedbacks because it's my first php-core hack. > > > > Thanks > > -- > > Samuel Déal > > samuel.d...@gmail.com > > > > -- > Laruence Xinchen Hui > http://www.laruence.com/ > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >