Method %s::%s() must take exactly 1 argument

Description

This error reports that a method requires one and only one argument. It applies to methods such as __set_state() and __get.

It may be surprising that it is a compile time error. Actually, the faulty method is a magic method, so PHP already knows what signature is expected for that method.

Example

<?php

class X {
    function __set_state() {}
}

?>

Literal Examples

  • Method X::__set_state() must take exactly 1 argument

Solutions

  • Use one argument for this method.

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>`_.