Skip to content

__sleep() is deprecated in PHP 8.5 #162

Description

@swissspidy

NOTE: Please file security related issues to security@mabe.berlin
to be able to coordinate releases across dependent projects privately.

Detailed description:

PHP 8.5 deprecates the __sleep() and __wakeup() magic methods, see https://wiki.php.net/rfc/deprecations_php_8_5.

The recommendation is to implement __serialize() instead (or in addition, if support for old PHP versions is necessary)

This package uses it here:

php-enum/src/Enum.php

Lines 89 to 97 in 7159809

/**
* @throws LogicException Serialization is not supported by default in this pseudo-enum implementation
*
* @psalm-return never-return
*/
final public function __sleep()
{
throw new LogicException('Serialization is not supported by default in this pseudo-enum implementation');
}

Steps to reproduce:

  1. Run on PHP 8.5

Expected behavior:

No deprecation warnings :)

Environment:

Important information of your environment.

  • PHP Version: PHP 8.5.0-dev (cli) (built: Sep 10 2025 21:48:22) (NTS)
  • PHP Extensions + Versions: ...
  • PHP Configuration: ...
  • ...

Additional context:

N/A

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions