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

EnumMap implements Serializable but it's not serializable #91

Closed marc-mabe closed 7 years ago

marc-mabe commented 7 years ago

Currently the EnumMap is based on SplObjectStorage. For whatever reason SplObjectStorage implements Serializable but the enumerator objects are not serializable (by default).

    public function testEnumMapSerializable()
    {
        $enumMap = new EnumMap(EnumBasic::class);
        $this->assertTrue($enumMap instanceof Serializable);

        $enumMap->offsetSet(EnumBasic::ONE, 'one');
        serialize($enumMap);
    }

// -> LogicException: Enums are not serializable