Today __sleep() does two jobs: it runs cleanup code before an object is serialized, and it returns an array listing which properties to save. This RFC from Dmytro Kulyk lets __sleep() return null or nothing at all, so it only runs your cleanup and PHP then serializes the object the normal way.
How it works
Before, you had to list every property you wanted to keep:
class A { public $a; function __sleep() { $this->cleanup(); return ['a']; } }
With this RFC, you can skip the list:
class A { public $a; function __sleep(): void { $this->cleanup(); // no return → engine performs default serialization } }
What __sleep() returns decides what happens next:
- An array: no change. Only the listed properties are serialized.
nullor nothing: your code runs, then PHP serializes the object as if__sleep()didn't exist.- Anything else: PHP emits a warning, then falls back to the same default serialization.
The warning message is also updated to mention that you can return null or nothing.
The RFC treats this as one part of a larger plan. Two other proposed attributes would cover the rest, #[NoSerialize] to skip a property and #[NotSerializable] to block a whole class, but those are separate RFCs.
What it means for existing code
The RFC calls the impact low. Today, if __sleep() returns something that isn't an array, PHP warns and serializes the object as NULL. With this change, returning null or nothing serializes the whole object instead. Returning some other type still warns, but it also serializes the whole object. Returning an array or throwing an exception works the same as before.
Where it stands
The RFC is a draft, version 0.4, dated October 20, 2025, and targets PHP 8.6 or 9.0. There's an implementation pull request, but no vote has happened.