EnumTrait: override __clone, __sleep, __wakeup to prevent duplication

This commit is contained in:
Dylan K. Taylor 2021-06-29 19:55:43 +01:00
parent 7ba573db77
commit 1170c8fe13
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -97,4 +97,16 @@ trait EnumTrait{
public function equals(self $other) : bool{
return $this->enumName === $other->enumName;
}
public function __clone(){
throw new \LogicException("Enum members cannot be cloned");
}
public function __sleep(){
throw new \LogicException("Enum members cannot be serialized");
}
public function __wakeup(){
throw new \LogicException("Enum members cannot be unserialized");
}
}