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 @@ -224,4 +224,18 @@ public function testCloneNotCallableAndThrowsLogicException()
224
224
$ this ->setExpectedException ('LogicException ' );
225
225
$ reflectionMethod ->invoke ($ enum );
226
226
}
227
+
228
+ public function testNotSerializable ()
229
+ {
230
+ $ enum = EnumBasic::ONE ();
231
+
232
+ $ this ->setExpectedException ('LogicException ' );
233
+ serialize ($ enum );
234
+ }
235
+
236
+ public function testNotUnserializable ()
237
+ {
238
+ $ this ->setExpectedException ('LogicException ' );
239
+ unserialize ("O:32: \"MabeEnumTest\TestAsset\EnumBasic \":0:{} " );
240
+ }
227
241
}
You can’t perform that action at this time.
0 commit comments