From ae40e4d07de588029cd06f0fce6cdc878de7d926 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas <nicolas.grekas@gmail.com> Date: Tue, 2 Apr 2019 17:51:53 +0200 Subject: [PATCH] Prevent destructors with side-effects from being unserialized --- Legacy/SymfonyTestsListenerTrait.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Legacy/SymfonyTestsListenerTrait.php b/Legacy/SymfonyTestsListenerTrait.php index 6333c4fd..2c7391a0 100644 --- a/Legacy/SymfonyTestsListenerTrait.php +++ b/Legacy/SymfonyTestsListenerTrait.php @@ -83,6 +83,16 @@ public function __construct(array $mockedNamespaces = array()) } } + public function __sleep() + { + throw new \BadMethodCallException('Cannot serialize '.__CLASS__); + } + + public function __wakeup() + { + throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); + } + public function __destruct() { if (0 < $this->state) {