clone(): Argument #1 ($object) must be of type object, %s given¶
Description¶
This is the error message when an attempt of cloning is made on an piece of data that is not an object.
Example¶
<?php
clone(1);
?>
Literal Examples¶
clone(): Argument #1 ($object) must be of type object, int given
clone(): Argument #1 ($object) must be of type object, string given
clone(): Argument #1 ($object) must be of type object, array given
Solutions¶
Check that the cloned value is actually an object.
In previous PHP versions, this error message used to be __clone method called on non-object.
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>`_.