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

From: Date: Thu, 11 Sep 2025 09:39:00 +0000
Subject: Re: [RFC] Soft-Deprecate __sleep() and __wakeup()
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-128673@lists.php.net to get a copy of this message
> Sebastian Bergmann <sebastian@php.net> hat am 11.09.2025 08:33 CEST geschrieben: > > > 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 This serialize is currently not very optimal. E.g. Pest uses "--coverage-php" and in my setup SebastianBergmann\CodeCoverage\Report\PHP::process() then consumes gigabytes of ram, >500M on disk and >20s extra time to get the coverage report. Regards Thomas

« previous php.internals (#128673) next »