Releases: rexlabsio/enum-php
Releases · rexlabsio/enum-php
2.4.0 - PHP 8.3 and 8.4 compatibility release
2.3.0 - PHP 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2
PHP compatibility release.
Now supports and has been tested with PHP 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2
2.2.0 - Feature: Add expressive check methods
- Adds
isNot,isAnyOf,isNoneOfexpressive methods: See #12 for more context
2.1.0 - Feature: get all instances
Added
- A static helper method to get all instances in an enum
MyEnum::instances()
2.0.0 - New API (BC)
2.0.0
This release is a significant overhaul of the existing API, and therefore introduces breaking changes.
See the list of updates below, and consult the README for examples and details of the new API.
- Add Enum::instanceFromKey($key)
- Breaking Change
$instance->identifierto$instance->name() - Breaking Change
Enum::identifiers()toEnum::names() - Breaking Change
Enum::getKeyForIdentfier()toEnum::keyForName() - Breaking Change
Enum::valueFor()toEnum::valueForKey() - Add
Enum::nameForKey()to get the constant name for a given key - Breaking Change
Enum::exists()toEnum::isValidKey() - Breaking Change
Enum::checkExists()toEnum::requireValidKey() - Fix
$instance->key()to handle non-string keys - Fix
$instance->is()to handle non-string keys - Fix late-static binding in some methods which referred to
self:: - Add
Enum::instanceFromName($name)to get an instance via name (alternative to Enum::NAME()) - Change implementation of
Enum::instanceFromKey($key)to use array_search - Breaking Change: the default provided static
map()method will return an array of constant keys mapped tonull.
Previously it returned an empty array[]when not overridden. In practice, this may not effect userland code. - Breaking Change: you can no longer provide a non-keyed array in an
map()method implemented
in your sub-class. This method should be used to map keys to values (if necessary). A default map() method is provided
which maps keys tonullvalues. - Breaking Change
Enum::fromValue($val)has been renamed toEnum::keyForValue() - Breaking Change: removed
Enum::flip() - Breaking Change
Enum::constantMap()toEnum::namesAndKeys() - Updated README to reflect API changes
- Add
Enum::valueForName($name)for completeness
1.1.0 - Constants By Value
Adds new functionality.
1.0.0 - Initial release
Initial release of enum library.
See README.md for details about this package.