Skip to content

Array with anonymous functions flagged unnecessarily #9614

@jackbentley

Description

@jackbentley

Bug report

Given an array of anonymous functions, when called by a variable as an index, PHPStan will say invoked with more parameters than required.

This seems to only happen when the functions have return statements

Code snippet that reproduces the problem

https://phpstan.org/r/457fc68b-2155-441f-8e06-ce502c914429

Expected output

No issues should be detected.

Without return statements no errors flagged: https://phpstan.org/r/af3a2d19-91dc-4e32-8a7f-dacafce7f3d5

Seems to also depend on the order of the items in the array - it takes the first function only:
First function with 2 params: https://phpstan.org/r/176fd1de-e513-40b4-9cd3-f03c5ad19bac
First function with 1 param: https://phpstan.org/r/08c60ad3-6a2c-4d20-b492-b7c37bab40b0

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

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions