Re: [RFC] Soft-Deprecate __sleep() and __wakeup()

From: Date: Thu, 11 Sep 2025 06:33:50 +0000
Subject: Re: [RFC] Soft-Deprecate __sleep() and __wakeup()
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-128670@lists.php.net to get a copy of this message
Am 10.09.2025 um 15:23 schrieb Jakub Zelenka:
If __sleep is used to serialize private properties (not all but just some), then those property names are stored in the mangled format ("\x00" . self::class . "\x00" prefix). It means to make it compatible in __serialize, the application has to mangle property names - this can be done either manually prefixing the name or using get_mangled_object_vars and filter the mangled names. Alternatively it could use __serialize with the new names but then it will need to deal with new and old (mangled) formats in __unserialize. In any case it means that the users will be required to deal with the mangled property name and get some understanding of mangling.
On the off-chance this might be useful for somebody following this thread, this is what the prefixing approach looks like: https://github.com/sebastianbergmann/php-code-coverage/blob/12.3.7/src/CodeCoverage.php#L92-L110

« previous php.internals (#128670) next »