---
title: "lint/style/no-sleep-wakeup"
pagination: false
---

{/* Generated by scripts/gen-rule-docs.py. Edit mapping.toml, not this file. */}

<RuleId id="lint/style/no-sleep-wakeup" />

In the [`modernize`](/docs/rules/sets/modernize) set. Unsafe fix: it can change behaviour. Gated by php-version.

## What it does

Replace __sleep()/__wakeup() with __serialize()/__unserialize().

## Configuration

```toml title="pun.toml"
[lint.rules]
"style/no-sleep-wakeup" = "error"
```

To skip it in some files, add an [override](/docs/configuration/pun-toml#lint) or a [`@pun-ignore-file`](/docs/configuration/ignore-comments) comment.

## Options

| Name | Type | Allowed values | Default | Upstream name |
| --- | --- | --- | --- | --- |
| `checks` | `list` | `sleep`, `wakeup` | `["sleep", "wakeup"]` | None (Pun's own) |

## Replaces

- [`modern_serialization_methods`](https://cs.symfony.com/doc/rules/class_notation/modern_serialization_methods.html) (php-cs-fixer, risky)
- [`SleepToSerialize`](https://getrector.com/rule-detail/sleep-to-serialize-rector) (rector)
- [`WakeupToUnserialize`](https://getrector.com/rule-detail/wakeup-to-unserialize-rector) (rector)

## Merged rules

These old IDs are now this rule. A config that still names one stops with an error. See [merged rules](/docs/migrate/merged-rules).

- `lint/classes/prefer-serialize-method`
- `lint/classes/prefer-unserialize-method`

[More lint/style rules](/docs/rules/lint/style) · [Edit this page](https://github.com/shipfastlabs/pun/edit/main/crates/pun-config/rules/mapping.toml)
