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
Currently the
EnumMap
is based onSplObjectStorage
. For whatever reasonSplObjectStorage
implementsSerializable
but the enumerator objects are not serializable (by default).