Releases: marc-mabe/php-enum
v4.1.0
v4.0.0
First stable release of new major version
We have worked a lot to make this library even more useful and also optimized the performance a lot!
To be able to do so we introduced a couple of BC breaks (please read the changes carefully) but we tried to keep them as small as possible.
Changes
-
Added Immutable
EnumSet
andEnumMap
API- Added
with*
methods which will not modify the current object but instead generate a new object - Now the iterable interface is using
IteratorAggregate
withGenerator
to move the iteration state into an own object and provides much better performance - The mutable API will stay untouched. This means that you have the choice to use either the mutable or immutable API depending on your use case.
- #109 #110 #118
- Added
-
Added methods to bulk modify an
EnumSet
andEnumMap
and to instantiate state- The constructor supports an
iterable
second argument to instantiate the state - Added methods
addIterable
,removeIterable
,withIterable
,withoutIterable
- The constructor supports an
-
Consistent Method Namings
- We have renamed the following methods to be consistent over all classes.
- The old method names are marked as deprecated and will trigger a deprecation notice in the last 4.x release and get removed in 5.x
EnumSet::attach
->EnumSet::add
EnumSet::detach
->EnumSet::remove
EnumSet::contains
->EnumSet::has
EnumMap::contains
->EnumMap::has
- #120 #121
-
Added Type-Hints
- All public methods have argument and return type-hints where possible.
-
PHP-7.1
- We have raised the required PHP version from 5.6 to 7.1 and removed HHVM support.
- This has been done to reduce internal complexity, to improve performance and to be able to define type-hints
BC-Breaks
-
As of moving from
Iterator
toIteratorAggregate
- removed methods - please use
foreach
directly or migrate togetIterator
insteadEnumSet::current
EnumSet::key
EnumSet::next
EnumSet::rewind
EnumSet::valid
EnumMap::current
EnumMap::key
EnumMap::next
EnumMap::rewind
EnumMap::valid
EnumMap::seek
- removed methods - please use
-
As of moving to
Genreator
- On iterating an
EnumSet
orEnumMap
the iterator position can move forward only Enum[Set|Map]->getIterator()->rewind()
throws an exception
- On iterating an
-
Soft Deprecations
EnumSet::attach
please useEnumSet::add
insteadEnumSet::detach
please useEnumSet::remove
insteadEnumSet::contains
please useEnumSet::has
insteadEnumMap::contains
please useEnumMap::has
instead
v4.0.0-rc1
First Release Candidate of new major version
We have worked a lot to make this library even more useful and also optimized the performance a lot!
To be able to do so we introduced a couple of BC breaks (please read the changes carefully) but we tried to keep them as small as possible.
Changes
-
Added Immutable
EnumSet
andEnumMap
API- Added
with*
methods which will not modify the current object but instead generate a new object - Now the iterable interface is using
IteratorAggregate
withGenerator
to move the iteration state into an own object and provides much better performance - The mutable API will stay untouched. This means that you have the choice to use either the mutable or immutable API depending on your use case.
- #109 #110 #118
- Added
-
Added methods to bulk modify an
EnumSet
andEnumMap
and to instantiate state- The constructor supports an
iterable
second argument to instantiate the state - Added methods
addIterable
,removeIterable
,withIterable
,withoutIterable
- The constructor supports an
-
Consistent Method Namings
- We have renamed the following methods to be consistent over all classes.
- The old method names are marked as deprecated and will trigger a deprecation notice in the last 4.x release and get removed in 5.x
EnumSet::attach
->EnumSet::add
EnumSet::detach
->EnumSet::remove
EnumSet::contains
->EnumSet::has
EnumMap::contains
->EnumMap::has
- #120 #121
-
Added Type-Hints
-
All public methods have argument and return type-hints where possible.
-
PHP-7.1
- We have raised the require PHP version from 5.6 to 7.1 and removed HHVM support.
- This has been done to reduce internal complexity, to improve performance and to be able to define type-hints
BC-Breaks
-
As of moving from
Iterator
toIteratorAggregate
- removed methods - please use
foreach
directly or migrate togetIterator
insteadEnumSet::current
EnumSet::key
EnumSet::next
EnumSet::rewind
EnumSet::valid
EnumMap::current
EnumMap::key
EnumMap::next
EnumMap::rewind
EnumMap::valid
EnumMap::seek
- removed methods - please use
-
As of moving to
Genreator
- On iterating an
EnumSet
orEnumMap
the iterator position can move forward only Enum[Set|Map]->getIterator()->rewind()
throws an exception
- On iterating an
-
Soft Deprecations
EnumSet::attach
please useEnumSet::add
insteadEnumSet::detach
please useEnumSet::remove
insteadEnumSet::contains
please useEnumSet::has
insteadEnumMap::contains
please useEnumMap::has
instead
v2.3.2
v3.1.1
v3.1.0
First Minor Release of 3.x
Changes
v3.1.0-rc1
v3.0.2
v3.0.1
v3.0.0
New Major Version
We have worked a lot to make this library even more useful and also optimized the performance a lot!
To be able to do so we introduced a couple of BC breaks (please read the changes carefully) but we tried to keep them as small as possible.
Changes
- #94 optimized
Enum::detectConstants()
using assertion to check for ambiguous enumerator values- this method is called once on initialize an enumeration
- #68 removed deprecated methods
- #69 bumped up PHP version to >=5.6
- new language features helps us to better maintain this library and provides better optimized code
- we decided to bump up the supported PHP version as PHP-5.3 is outdated for a long time now
- we decided to still keep PHP-5.6 (even if outdated as well) as this library is still compatible with HHVM. This way HHVM users can use this new version and have more time to migrate
- #87 added phpbench suite
- #73 EnumSet::setBinaryBitset*(): now throws an exception on out-of-range bits set
- #86 refactored EnumSet to be auto based on integer or binary bitset dependent on enumeration size
- Methods changed:
union()
,intersect()
,diff()
andsymDiff()
support one argument of$others
only
- Methods added:
public function getBit(int $ordinal) : bool
public function setBit(int $ordinal, bool $bit) : void
- Methods changed:
- #70 removed iterator flags for EnumMap
- the key will be the enumerator object and the value the assigned data
- #90 #91 #92 Refactor EnumMap
- if data are serializable the
EnumMap
is serializable, too - no longer based on
SplObjectStorage
- no longer implement
Serializable
- still implements
ArrayAccess
,Countable
andIterator
- new implements
SeekableIterator
- Methods removed:
public function attach($enumerator) : void
- please use
public function offsetSet($enumerator) : void
- or direct array access
$map[$enum] = $value
- please use
public function detach($enumerator): void
- please use
public function offsetUnset($enumerator) : void
- or direct array access
unset($map[$enum])
- please use
public addAll(SplObjectStorage $storage) : void
public getHash(object $object) : string
public removeAll(SplObjectStorage $storage) : void
public removeAllExcept(SplObjectStorage $storage) : void
public serialize(void) : string
public setInfo(mixed $data) : void
public unserialize(string $serialized) : void
- Methods changed:
public contains($enumerator) : bool
- same as
public offsetExists($enumerator) : bool
but returns true onNULL
values
- same as
- Methods added:
public function seek(int $pos) : void
public function getKeys() : Enum[]
public function getValues() : mixed[]
public function search($enumerator, bool $strict) : Enum|null
- if data are serializable the