Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array with anonymous functions flagged unnecessarily #9614

Closed
jackbentley opened this issue Jul 11, 2023 · 4 comments
Closed

Array with anonymous functions flagged unnecessarily #9614

jackbentley opened this issue Jul 11, 2023 · 4 comments
Labels
Milestone

Comments

@jackbentley
Copy link

jackbentley commented Jul 11, 2023

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

@ondrejmirtes
Copy link
Member

This is very similar to #9594

@ondrejmirtes
Copy link
Member

Oh, it's different, sorry.

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src#2902

Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants