Fork me on GitHub
a Sensio Labs Product

Exceptional Exception (v3.93.1) edition

Rule modern_serialization_methods

Use new serialization methods __serialize and __unserialize instead of deprecated ones __sleep and __wakeup.

Warning

This rule is RISKY

Risky when calling the old methods directly or having logic in the __sleep and __wakeup methods.

Examples

Example #1

--- Original
+++ New
 <?php class Foo {
-    public function __sleep() {}
-    public function __wakeup() {}
+    public function __serialize() {}
+    public function __unserialize(array $data) {}
 }

Rule sets

The rule is part of the following rule sets:

References

The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.