File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,24 @@ final private function __clone()
75
75
throw new LogicException ('Enums are not cloneable ' );
76
76
}
77
77
78
+ /**
79
+ * @throws LogicException Enums are not serializable
80
+ * because instances are implemented as singletons
81
+ */
82
+ final public function __sleep ()
83
+ {
84
+ throw new LogicException ('Enums are not serializable ' );
85
+ }
86
+
87
+ /**
88
+ * @throws LogicException Enums are not serializable
89
+ * because instances are implemented as singletons
90
+ */
91
+ final public function __wakeup ()
92
+ {
93
+ throw new LogicException ('Enums are not serializable ' );
94
+ }
95
+
78
96
/**
79
97
* Get the current selected value
80
98
*
Original file line number Diff line number Diff line change @@ -239,4 +239,18 @@ public function testCloneNotCallableAndThrowsLogicException()
239
239
$ this ->setExpectedException ('LogicException ' );
240
240
$ reflectionMethod ->invoke ($ enum );
241
241
}
242
+
243
+ public function testNotSerializable ()
244
+ {
245
+ $ enum = EnumBasic::ONE ();
246
+
247
+ $ this ->setExpectedException ('LogicException ' );
248
+ serialize ($ enum );
249
+ }
250
+
251
+ public function testNotUnserializable ()
252
+ {
253
+ $ this ->setExpectedException ('LogicException ' );
254
+ unserialize ("O:32: \"MabeEnumTest\TestAsset\EnumBasic \":0:{} " );
255
+ }
242
256
}
You can’t perform that action at this time.
0 commit comments