marc-mabe / php-enum

Simple and fast implementation of enumerations with native PHP
BSD 3-Clause "New" or "Revised" License
464 stars 36 forks source link

EnumSet should be based on a real BitSet #32

Closed marc-mabe closed 9 years ago

marc-mabe commented 10 years ago

Current implementation of EnumSet is a list of Enum instances but a real EnumSet should be based on a BitSet.

Because current implementation is a list and contains flags that only makes sense for a list fix this requires a bc break -> so mark it for 2.0.0

Question: Should the current list live as EnumList or should it be dropped completely because a list can simply be implemented by itself and makes sense only for explicit enumerations?

@prolic ping

marc-mabe commented 10 years ago

Current branch EnumSet_BitSet

prolic commented 10 years ago

I will take a look at the weekend.

prolic commented 10 years ago

As for the real EnumSet based on BitSet... go for it! Let's drop the EnumList implementation, or do you have a need for it?

Sorry for the late reply ;)

prgTW commented 10 years ago

do You have any ETA for this feature?

marc-mabe commented 10 years ago

@prgTW The feature is nearly ready. You can test it already https://github.com/marc-mabe/php-enum/blob/EnumSet_BitSet/src/MabeEnum/EnumSet.php. The only think missing is a check for 32 vs 64 bit platforms and throw an exception if the enum class has more enumerations defined.

I also tested it against GMP to support an unlimited number of enumeration definitions but it doesn't work and it's currently much slower - https://github.com/marc-mabe/php-enum/blob/EnumSet_BitSet/src/MabeEnum/EnumSet2.php

prgTW commented 10 years ago

@marc-mabe if You want to use GMP make ext-gmp required in composer.json.

32/64 bit check: 32bit: 4 === PHP_INT_SIZE 64bit: 8 === PHP_INT_SIZE