%s" is returned from __sleep() multiple times

Description

This error is emitted when one of the properties that has to be put to sleep is repeated in the returned array of __sleep(). All the duplicated properties are reported in one pass, although each of them only once. The warning is only triggered when the code is run.

Example

<?php

class X {
    private $data;

    public function __sleep() {
        return ['data', 'data', 'data'];
    }
}

// Create an instance and serialize it
$example = new Example('test');
$serialized = serialize($example);

?>

Literal Examples

  • data” is returned from __sleep() multiple time

Solutions

  • Make sure the properties names are all unique in the returned array.

Changed Behavior

This error may appear following an evolution in behavior, in previous versions. See ` <https://php-changed-behaviors.readthedocs.io/en/latest/behavior/.html>`_.