1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680
|
v4.7.0 - 28 Nov 2024
4.7.1 Fully Support PHP 8.2, 8.3 and 8.4 Latest
Improvements
Fully support PHP 8.2, 8.3 and 8.4 by @marc-mabe in #160
Clearify serialization error message by @marc-mabe in #161
Bugfixes
fix deprecation warning in EnumSet and EnumMap
v4.7.0 - 19 Apr 2022
Explicit Stringable interface Latest
Improvements
#156 Enums explicitly implements Stringable interface (with stub for PHP < 8)
v4.6.1 - 13 Feb 2022
Bugfixes
#155 fix error exception on clone $enum
v4.6.0 - 5 Jan 2022
Support PHP 8.1
Same as v4.6.0-rc1 but with updated dev dependencies
v4.6.0-rc1 - 4 Sep 2021
Support PHP 8.1
Improvements
#150 PHP-8.1 Support
Added Attribute ReturnTypeWillChange to EnumMap.offsetGet
Upgrade phpstan to ^1.0.4
Upgrade phpbench to ^0.12.96
Bugfixes
#150 PHP-8.1 Support
Added Attribute ReturnTypeWillChange to EnumMap.offsetGet
v4.4.0 - 12 Oct 2020
Fifth Minor Release of 4.x
Improvements
#147 #148 PHP-8 Support
- make Enum::__clone to be final protected instead of final private (we don't consider this a BC break) - thanks @shmurakami
- Restrict required PHP version to be ^7.1 or ^8.0
- Tests & Benchmark: Removed assertion polyfill code in bootstrap
- Tests: removed usage of assert_options
#149 Migrate from Travis CI + Scurinizer to Github Workflow + Codecov
- This simplifies test runs on specific PHP versions using official docker images including PHP-8
v4.3.0 - 27 Apr 2020
Third Minor Release of 4.x (Release Candidate)
Improvements
#138 #140 Static analyzer improvements for PHPStan & Psalm
- Generics for EnumSet & EnumMap
- Better argument and return type information
- purity markers for Psalm
#141 Added __debugInfo() for human readable internals of EnumSet & EnumMap for var_dump()
v4.3.0-rc1 - 26 Apr 2020
Third Minor Release of 4.x (Release Candidate)
Improvements
#138 #140 Static analyzer improvements for PHPStan & Psalm
- Generics for EnumSet & EnumMap
- Better argument and return type information
- purity markers for Psalm
#141 Added __debugInfo() for human readable internals of EnumSet & EnumMap for var_dump()
v4.2.0 - Dec 18, 2019
Second Minor Release of 4.x
Bugfixes
#137 fixed TypeError in EnumSet::getBinaryBitsetLe()
#134 fixed check of ambiguous values in Enum::byName()
Changes
#136 Added PHP-7.4 in CI
#125 PHP 7.4 serializer and wrap old Serializable methods for BC
#132 Micro optimizations
v4.1.1 - Sep 22, 2019
Bugfix release
Changes:
#131 fixed ordinal cache usage of Enum::getName() if ordinal=0
v4.1.0 - Jul 4, 2019
First Minor Release of 4.x
Changes
#126 Added EnumSet::isEmpty() and EnumMap::isEmpty()
v4.0.0 - May 21, 2019
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 and EnumMap API
Added with* methods which will not modify the current object but instead generate a new object
Now the iterable interface is using IteratorAggregate with Generator 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 methods to bulk modify an EnumSet and EnumMap and to instantiate state
The constructor supports an iterable second argument to instantiate the state
Added methods addIterable, removeIterable, withIterable, withoutIterable
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 to IteratorAggregate
removed methods - please use foreach directly or migrate to getIterator instead
EnumSet::current
EnumSet::key
EnumSet::next
EnumSet::rewind
EnumSet::valid
EnumMap::current
EnumMap::key
EnumMap::next
EnumMap::rewind
EnumMap::valid
EnumMap::seek
As of moving to Genreator
On iterating an EnumSet or EnumMap the iterator position can move forward only
Enum[Set|Map]->getIterator()->rewind() throws an exception
Soft Deprecations
EnumSet::attach please use EnumSet::add instead
EnumSet::detach please use EnumSet::remove instead
EnumSet::contains please use EnumSet::has instead
EnumMap::contains please use EnumMap::has instead
v4.0.0-rc1 - May 13, 2019
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 and EnumMap API
Added with* methods which will not modify the current object but instead generate a new object
Now the iterable interface is using IteratorAggregate with Generator 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 methods to bulk modify an EnumSet and EnumMap and to instantiate state
The constructor supports an iterable second argument to instantiate the state
Added methods addIterable, removeIterable, withIterable, withoutIterable
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 to IteratorAggregate
removed methods - please use foreach directly or migrate to getIterator instead
EnumSet::current
EnumSet::key
EnumSet::next
EnumSet::rewind
EnumSet::valid
EnumMap::current
EnumMap::key
EnumMap::next
EnumMap::rewind
EnumMap::valid
EnumMap::seek
As of moving to Genreator
On iterating an EnumSet or EnumMap the iterator position can move forward only
Enum[Set|Map]->getIterator()->rewind() throws an exception
Soft Deprecations
EnumSet::attach please use EnumSet::add instead
EnumSet::detach please use EnumSet::remove instead
EnumSet::contains please use EnumSet::has instead
EnumMap::contains please use EnumMap::has instead
v3.1.1 - Feb 2, 2019
First Patch Release of 3.1.x
Changes
#107 fixed array to string conversion in EnumMap::offsetGet()
copyright 2019
\count() instead of count()
static::class instead of get_class($this)
more strict argument type for Enum::get()
v3.1.0 - Feb 2, 2019
First Minor Release of 3.x
Changes
#96 #106 Support arrays as enum values in phpDoc enhancement
#105 added Enum::hasValue() and Enum::hasName()
added missing phpdoc @throws
fixed return type in phpdoc of EnumSet::getValues()
fixed argument type in phpdoc of EnumMap::search()
fixed first argument name in phpdoc of Enum:has()
v3.1.0-rc1 - Jan 21, 2019
First Release Candidate of new minor version
Changes
#96 #106 Support arrays as enum values in phpDoc enhancement
#105 added Enum::hasValue() and Enum::hasName()
v3.0.2 - 14 Sep 2018
Patch release of 3.0.x
Changes
#99 : Minor phpdoc syntax fix
BC-breaks
none
v3.0.1 - 22 May 2018
Patch release of 3.0.x
Changes
#95 : Add description to assert()
#98 : HHVM >3.18.4 & >3.20.2 reports as PHP-7.1 but does not support constant visibility
Micro-Optimized Enum::by*methods
BC-breaks
none
v3.0.0 - 5 Nov 2017
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() and symDiff() support one argument of $others only
Methods added:
public function getBit(int $ordinal) : bool
public function setBit(int $ordinal, bool $bit) : void
#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 and Iterator
new implements SeekableIterator
Methods removed:
public function attach($enumerator) : void
please use public function offsetSet($enumerator) : void
or direct array access $map[$enum] = $value
public function detach($enumerator): void
please use public function offsetUnset($enumerator) : void
or direct array access unset($map[$enum])
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 on NULL values
Methods added:
public function seek(int $pos) : void
public function getKeys() : Enum[]
public function getValues() : mixed[]
public function search($enumerator, bool $strict) : Enum|null
v3.0.0-rc3 - 28 Oct 2017
Third Release Candidate of new major version
Changes
#94 optimized Enum::detectConstants() using assertion to check for ambiguous enumerator values
this method is called once on initialize an enumeration
BC-breaks:
#94 Now on initialize an enumeration with ambiguous enumerator values an AssertionError will be thrown (PHP>=7) or a warning will be triggered (PHP<=5.6) only in case assertions are enabled (development mode) else no error will be thrown. Please read here how assertions work.
v3.0.0-rc2 - 25 Oct 2017
Second Release Candidate of new major version
Changes
optimized EnumSet::count() up to 40%
BC-breaks:
none
v3.0.0-rc1 - 19 Oct 2017
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
#68 remove 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() and symDiff() support one argument of $others only
Methods added:
public function getBit(int $ordinal) : bool
public function setBit(int $ordinal, bool $bit) : void
#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 and Iterator
new implements SeekableIterator
Methods removed:
public function attach($enumerator) : void
please use public function offsetSet($enumerator) : void
or direct array access $map[$enum] = $value
public function detach($enumerator): void
please use public function offsetUnset($enumerator) : void
or direct array access unset($map[$enum])
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 on NULL values
Methods added:
public function seek(int $pos) : void
public function getKeys() : Enum[]
public function getValues() : mixed[]
public function search($enumerator, bool $strict) : Enum|null
v2.3.2 - Mar 16, 2019
Bugfix release
Changes:
#98 Backported HHVM >3.18.4 & >3.20.2 reports as PHP-7.1 but does not support constant visibility
BC-breaks:
none
v2.3.1 - 21 Dec 2016
Bugfix release
Changes:
#82 EnumSet::setBinaryBitset*(): fixed logic of 'truncate out-of-range bits of last byte'
v2.3.0 - 19 Dec 2016
Feature release of the 2.x branch.
(No changes since 2.3.0-rc1)
New:
#63: EnumSet: support for Little- and Big-Endian binary bitsets
Added EnumSet::getBinaryBitsetLe() : string
Added EnumSet::setBinaryBitsetLe(string $bitset)
Added EnumSet::getBinaryBitsetBe() : string
Added EnumSet::setBinaryBitsetBe(string $bitset)
#64: EnumSet: added isEqual(), isSubset() and isSuperset()
Added EnumSet::isEqual(EnumSet $other) : bool
Added EnumSet::isSubset(EnumSet $other) : bool
Added EnumSet::isSuperset(EnumSet $other) : bool
#66: EnumSet: added methods union(), intersect(), diff() and symDiff()
Added EnumSet::union(EnumSet ...$others) : EnumSet
Added EnumSet::intersect(EnumSet ...$others) : EnumSet
Added EnumSet::diff(EnumSet ...$others) : EnumSet
Added EnumSet::symDiff(EnumSet ...$others) : EnumSet
#65: EnumSet: added getEnumerators(), getNames() and getValues()
Added EnumSet::getEnumerators() : Enum[]
Added EnumSet::getValues() : mixed[]
Added EnumSet::getNames() : string[]
#78: Added static Enum::getValues(), Enum::getNames() and Enum::getOrdinals()
Added Enum::getValues() : mixed[]
Added Enum::getNames() : string[]
Added Enum::getOrdinals() : int[]
#80: refactored Enum::getBy* to Enum::by*
Renamed Enum::getByName() -> Enum::byName()
Renamed Enum::getByOrdinal() -> Enum::byName()
Added Enum::byValue()
#59: handle class constant visibility added in PHP-7.1
#67: optimized EnumSet::count() by 30% to 240%
#75: optimized EnumSet by using EnumSet properties directly instead of getter methods
##Fixed:
#71: EnumSet::setBinaryBitset*(): out-of-range bits of last byte not truncated
#77: Missing additional check on Enum::is() to return TRUE in some circumstances
Deprecations:
#63 :EnumSet::getBitset() : string
#63: EnumSet::setBitset(string $bitset)
#79: Enum::clear()
#80: Enum::getByName()
#80: Enum::getByOrdinal()
v2.3.0-rc1 - 7 Dec 2016
New:
#63: EnumSet: support for Little- and Big-Endian binary bitsets
Added EnumSet::getBinaryBitsetLe() : string
Added EnumSet::setBinaryBitsetLe(string $bitset)
Added EnumSet::getBinaryBitsetBe() : string
Added EnumSet::setBinaryBitsetBe(string $bitset)
#64: EnumSet: added isEqual(), isSubset() and isSuperset()
Added EnumSet::isEqual(EnumSet $other) : bool
Added EnumSet::isSubset(EnumSet $other) : bool
Added EnumSet::isSuperset(EnumSet $other) : bool
#66: EnumSet: added methods union(), intersect(), diff() and symDiff()
Added EnumSet::union(EnumSet ...$others) : EnumSet
Added EnumSet::intersect(EnumSet ...$others) : EnumSet
Added EnumSet::diff(EnumSet ...$others) : EnumSet
Added EnumSet::symDiff(EnumSet ...$others) : EnumSet
#65: EnumSet: added getEnumerators(), getNames() and getValues()
Added EnumSet::getEnumerators() : Enum[]
Added EnumSet::getValues() : mixed[]
Added EnumSet::getNames() : string[]
#78: Added static Enum::getValues(), Enum::getNames() and Enum::getOrdinals()
Added Enum::getValues() : mixed[]
Added Enum::getNames() : string[]
Added Enum::getOrdinals() : int[]
#80: refactored Enum::getBy* to Enum::by*
Renamed Enum::getByName() -> Enum::byName()
Renamed Enum::getByOrdinal() -> Enum::byName()
Added Enum::byValue()
#59: handle class constant visibility added in PHP-7.1
#67: optimized EnumSet::count() by 30% to 240%
#75: optimized EnumSet by using EnumSet properties directly instead of getter methods
##Fixed:
#71: EnumSet::setBinaryBitset*(): out-of-range bits of last byte not truncated
#77: Missing additional check on Enum::is() to return TRUE in some circumstances
Deprecations:
#63 :EnumSet::getBitset() : string
#63: EnumSet::setBitset(string $bitset)
#79: Enum::clear()
#80: Enum::getByName()
#80: Enum::getByOrdinal()
v2.2.1 - 6 Sep 2016
Bugfix release
Changes:
#60 Infinitive loop on counting an empty set based on an empty enumeration
v2.2.0 - 4 Oct 2015
Feature release of the 2.x branch.
Changes:
#53 Added new method Enum::has()
v1.3.0 - 4 Oct 2015
Feature release of the 1.x branch.
Changes:
#54 Added new method Enum::has()
v2.1.0 - 22 Jun 2015
Feature release of the 2.x branch.
Changes:
#52 added EnumSerializableTrait for making enumerations serializable
#51 EnumSet: dynamic bitset size - no longer limited to 32/64 enumerators
#51 EnumSet: added methods [get|set]Bitset
v2.0.0 - 24 Feb 2015
Changes:
Inherited enumerations will be handled as own enumeration types
EnumSet is based on a real bitset now
Removed unnecessary source folder for PSR-4 autloading
Added Enum::getEnumerators()
BC-breaks:
EnumSet: Max. possible enumerators are limited by the size of an integer (32 or 64)
Enum::is() no longer returns TRUE on inherited enumerations
v2.0.0-beta1 - 9 Feb 2015
Changes:
* Inherited enumerations will be handled as own enumeration types
* EnumSet is based on a real bitset now
* Removed unnecessary source folder for PSR-4 autloading
* Added Enum::getEnumerators()
BC-breaks:
* EnumSet: Max. possible enumerators are limited by the size of an integer (32 or 64)
* Enum::is() no longer returns TRUE on inherited enumerations
v1.2.0 - 22 May 2014
v1.1.0 - 3 Apr 2014
This is a feature and bugfix release
v1.0.0 - 15 Oct 2013
Changes since 1.0.0-beta2:
Enumeration values will be compared using strict comparison
__toString() returns the name by default and is no longer final
v1.0.0-beta2 - 23 Sep 2013
Changes:
PHP 5.3 will be required
Moved to namespaces
BC break how to instantiate a new enumeration (please read usage information)
It's no longer possible to define a default value
You can define a method to instantiate it like UserStatus::getDefault()
Now instances of the same enumeration holds the same instance (singleton)
Now getConstants() is static
New Features:
Implemented EnumMap
Implemented EnumSet
Added ordinal information and make it possible to instantiate it from
v1.0.0-beta1 - 14 Oct 2013
First beta
|