6
6
use Dbalabka \Enumeration \Exception \EnumerationException ;
7
7
use Dbalabka \Enumeration \Exception \InvalidArgumentException ;
8
8
use Dbalabka \StaticConstructorLoader \StaticConstructorInterface ;
9
+ use Serializable ;
9
10
use function array_search ;
10
11
use function get_class_vars ;
11
12
use function sprintf ;
18
19
*
19
20
* @author Dmitry Balabka <[email protected] >
20
21
*/
21
- abstract class Enumeration implements StaticConstructorInterface
22
+ abstract class Enumeration implements StaticConstructorInterface, Serializable
22
23
{
23
24
const INITIAL_ORDINAL = 0 ;
24
25
@@ -158,6 +159,7 @@ final public function __clone()
158
159
159
160
/**
160
161
* Serialization is not allowed right now. It is not possible to properly serialize the singleton.
162
+ * See the documentation for workaround.
161
163
*/
162
164
final public function __sleep ()
163
165
{
@@ -168,4 +170,24 @@ final public function __wakeup()
168
170
{
169
171
throw new EnumerationException ('Enum unserialization is not allowed ' );
170
172
}
173
+
174
+ final public function __serialize ()
175
+ {
176
+ throw new EnumerationException ('Enum serialization is not allowed ' );
177
+ }
178
+
179
+ final public function __unserialize ()
180
+ {
181
+ throw new EnumerationException ('Enum unserialization is not allowed ' );
182
+ }
183
+
184
+ final public function serialize ()
185
+ {
186
+ throw new EnumerationException ('Enum serialization is not allowed ' );
187
+ }
188
+
189
+ final public function unserialize ($ data )
190
+ {
191
+ throw new EnumerationException ('Enum unserialization is not allowed ' );
192
+ }
171
193
}
0 commit comments