Skip to content

False positive parameter count error for static method named "add" #13556

@kwizer15

Description

@kwizer15

Bug report

PHPStan incorrectly reports a parameter count error when calling a static method named add with optional parameters. The error completely disappears if the method is renamed to any other name, suggesting an internal conflict or name resolution issue specific to the name "add".

Code snippet that reproduces the problem

https://phpstan.org/r/53c25855-1d03-4347-909a-2eb06f8febad

Expected output

No error should be reported as the call self::add('a',[]) is perfectly valid PHP: it provides 2 parameters for a method that accepts 1 required + 1 optional parameter.

Did PHPStan help you today? Did it make you happy in any way?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions