Skip to content

EnumMap implements Serializable but it's not serializable #91

Closed
@marc-mabe

Description

@marc-mabe

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

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions