xp-framework/xp-framework — pull request #178 by ohinckel (2012-07-30 05:51:09+00:00)
Title: Add helper functions to lang.Enum to retrieve values

The most enum classes already have helper functions implemented to retrieve the elements by name or ordinal value. These functions make use of the `lang.Enum`s helper functions `lang.Enum::valueOf()` or `lang.Enum::valuesOf()` to get the values. It was not possible to have these helper function in the base class, since you need to know which Enum sub-class you're currently dealing with in the super class.

With PHP 5.3.0 a feature calles late static binding (http://de3.php.net/manual/en/language.oop5.late-static-bindings.php) was implemented, which can be used to retrieve this information. With this, it's now possible to implement such helper functions directly in the base class.

This patch extends `lang.Enum` class to provide the following helper function to retrieve enum values:
* `lang.Enum::getByName()` - will retrieve an enum value by their name
* `lang.Enum::getByOrdinal()` - will retrieve an enum value by their ordinal value
* `lang.Enum::values()` - will return a list of all enum values

Since it requires PHP >=5.3.0, this pull request will also increase the XP framework requirements for PHP.