Method %s::%s() must take exactly 2 arguments

Description

This error reports that a method requires two and only two arguments. It applies to methods such as __set().

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() {}
}

?>

Literal Examples

  • Method X::__set() must take exactly 2 arguments

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