Parameter $%s of %s hook %s::$%s must not be variadic

Description

A set property hook must accept exactly one, ordinary parameter: the incoming value. Declaring it as variadic with ... does not make sense, since the hook is always called with exactly one value, never with a variable number of arguments.

Example

<?php

class X
{
    public string $property {
        set(string ...$value) {
            $this->property = implode(',', $value);
        }
    }
}

?>

Literal Examples

  • Parameter $value of set hook X::$property must not be variadic

Solutions

  • Remove the ... from the hook’s parameter, and declare it as a regular parameter.

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