%s hook of property %s::$%s must accept exactly one parameters¶
Description¶
When the set hook of a property is declared with an explicit parameter list, that list must contain exactly one parameter: the value being assigned. Declaring zero, two, or more parameters is not allowed.
This is different from omitting the parenthesis altogether, in which case the hook implicitly receives the value through a variable named $value.
Example¶
<?php
class X
{
public string $property {
set($a, $b) {
$this->property = $a;
}
}
}
?>
Literal Examples¶
set hook of property X::$property must accept exactly one parameters
Solutions¶
Keep only one parameter in the hook’s parameter list.
Remove the parameter list entirely and use the implicit
$valuevariable instead.
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>`_.