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

Bogus certainty of empty array inside delayed-use closure #8292

Closed
dktapps opened this issue Nov 4, 2022 · 2 comments · Fixed by phpstan/phpstan-src#1983
Closed

Bogus certainty of empty array inside delayed-use closure #8292

dktapps opened this issue Nov 4, 2022 · 2 comments · Fixed by phpstan/phpstan-src#1983
Labels
Milestone

Comments

@dktapps
Copy link
Contributor

dktapps commented Nov 4, 2022

Bug report

PHPStan cannot be certain of class field types inside a closure, regardless of whether they were initialized outside of the closure.

Code snippet that reproduces the problem

https://phpstan.org/r/f9c6e122-a753-4fdf-b729-a5523443e71d

Expected output

No error should be reported. By the time the closure is invoked, the array may contain something.

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

It's cool to see all the new stuff brought by 1.9

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Nov 5, 2022
@rajyan
Copy link
Contributor

rajyan commented Nov 7, 2022

I think I can get to work on this today.
Related PR’s
phpstan/phpstan-src#1934
phpstan/phpstan-src#1929
I think we need to invalidate all static expressions and $this at least, both for anonymous functions (which should be working except for use variable related expressions like this issue) and arrow functions (not invalidated now).
Not sure if there are other expressions that should be invalidated for delayed uses which are not static.

@github-actions
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 Dec 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants