Requests for comment/Typesafe enums

This RFC proposes a mechanism for typesafe enums. An implementation with tests and examples is provided.

Problem statement
Proper use of enums can improve code quality in several ways. Enums are a native construct in many languages, but not in PHP. In MediaWiki, class constants are normally used instead. However, PHP developers often roll enum implementations that are as good or nearly as good as native constructs in other languages.

Adding an enum mechanism to core would provide MediaWiki code the benefits of fully featured enums, including improved type safety, information hiding, error message readability, helper functions on sets of enum values, and extensibility.

Options
Options include:
 * Do nothing. There's nothing inherently wrong with just using class constants.
 * Use PHP's experimental SplEnum class. Disadvantages: this class is unintuitive to use, since enum consumers must instantiate enum values. Also, it's needlessly crufty—enum declarations still assign integers to each enum!
 * Build something better ourselves. Hopefully the proposed implementation, described below, fits the bill.