File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,22 @@ final public function __clone()
16
16
throw new SingletonException ('You can not clone a singleton. ' );
17
17
}
18
18
19
+ /**
20
+ * @throws SingletonException
21
+ */
22
+ final public function __sleep ()
23
+ {
24
+ throw new SingletonException ('You can not serialize a singleton. ' );
25
+ }
26
+
27
+ /**
28
+ * @throws SingletonException
29
+ */
30
+ final public function __wakeup ()
31
+ {
32
+ throw new SingletonException ('You can not deserialize a singleton. ' );
33
+ }
34
+
19
35
/**
20
36
* @return static
21
37
*/
Original file line number Diff line number Diff line change @@ -45,4 +45,12 @@ public function testClone()
45
45
$ sample2 = clone $ sample1 ;
46
46
}
47
47
48
+ /**
49
+ * @expectedException \ByJG\DesignPattern\SingletonException
50
+ */
51
+ public function testSerialize ()
52
+ {
53
+ $ sample1 = Sample1::getInstance ();
54
+ $ serialize = serialize ($ sample1 );
55
+ }
48
56
}
You can’t perform that action at this time.
0 commit comments