/** * Registers the reviver with the serializer. * * @throws UnserializationException */ public function __wakeup() { try { Serializer::registerReviver($this); } catch (\Exception $e) { // Preserving the exception trace by re-throwing or nesting crashes PHP... throw new UnserializationException($e->getMessage()); } }