Skip to content

Variadic parameters are not considered optional #3798

@dktapps

Description

@dktapps

Bug report

It seems like PHPStan thinks that variadic arguments are mandatory in some circumstances. However, they are always optional, and their default value is an empty array-of-type.

Locally I was able to fix this by adding an isVariadic() check to this condition: https://github.com/phpstan/phpstan-src/blob/a21012d142b476ec5a59366319c098bb8dc40afd/src/Rules/FunctionCallParametersCheck.php#L61
However, considering that the bug doesn't appear in all circumstances, I'm led to believe that this is a specific bug within the PHPDoc type handling, but I don't know where to look or where to find tests for it.

Code snippet that reproduces the problem

https://phpstan.org/r/80084b34-01d4-473b-a2b8-99077b55152b

Expected output

No error should be reported.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions