I think that your proposal looks good, but I'd like to suggest a few changes. First of all, I'd like to see the association with integers removed. An enum instance shouldn't just be a name for an integer, it should be more like a singleton instance of a special kind of class that can only ever have a predefined set of named instances. There should be no value associated with it.
Secondly, there already exists the capacity for arbitrary classes to be used in foreach and count you just have to implement Iterator and Countable. Other interfaces that all enums might want to implement automatically are ArrayAccess and Serializable. This would just require the enum itself to be an object (maybe of type enum or something) such that it can implement the relevant methods. http://www.php.net/manual/en/class.iterator.php http://php.net/manual/en/class.countable.php On Tue, Feb 21, 2012 at 11:45 PM, Samuel Deal <samuel.d...@gmail.com> wrote: > Hi all, > > I really missed enums in PHP, > 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 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php