Cannot declare variadic promoted property¶
Description¶
Properties may be declared, as an parameter in a constructor. Then, they also act as an parameter, and a local variable.
Variadic option is a parameter only option, which pack all the remaning arguments in the final parameter.
Variadic option makes no sense in a property definition, as only one value is stored there.
Example¶
<?php
class X {
function __construct(
private string ...$x
) {}
}
?>
Solutions¶
Remove the property definition from the constructor: keep the argument use the variadic, and define the property in the traditional way.
Remove the variadic option.