Requests for comment/Typesafe enums

This RFC proposes that a mechanism for creating typesafe enums be included in core. 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 usually used instead. However, it seems that PHP developers often roll their own enum implementations that are as good or nearly as good as the 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, and helper functions on the set of values of a given type).

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 the enum consumers must instantiate enum values. Also, it's needlessly verbose—enum declarations still assign integer values!
 * Build something better ourselves. Hopefully the proposed implementation, described below, fits the bill.