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 destructuring: Variable always exists and is not falsy. #7724

Closed
JoniJnm opened this issue Jul 31, 2022 · 3 comments · Fixed by phpstan/phpstan-src#1586
Closed

Array destructuring: Variable always exists and is not falsy. #7724

JoniJnm opened this issue Jul 31, 2022 · 3 comments · Fixed by phpstan/phpstan-src#1586

Comments

@JoniJnm
Copy link

JoniJnm commented Jul 31, 2022

Bug report

phpstan asummes destructuring array as not empty

Code snippet that reproduces the problem

https://phpstan.org/r/645cd80c-ea2b-41f2-9399-11bae7aca398

Expected output

No errors

@JoniJnm JoniJnm changed the title Variable always exists and is not falsy. Array destructuring: Variable always exists and is not falsy. Jul 31, 2022
@herndlm
Copy link
Contributor

herndlm commented Jul 31, 2022

Yep, as you wrote already: looks like an array creation problem using destructuring. It even happens with a single array. See https://phpstan.org/r/2e4cb1ab-2d1c-43cb-aed7-c65790248dcd

I think I recently fixed a similar thing in array_push, either way it should be a relatively easy fix.

@alexander-schranz
Copy link

alexander-schranz commented Aug 1, 2022

Another example: https://phpstan.org/r/f1e8a5dc-25f1-44c2-8aa5-d175b15a545f / https://3v4l.org/Ioup2 from my duplicated issue: #7736

@github-actions
Copy link

github-actions bot commented Sep 6, 2022

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

Successfully merging a pull request may close this issue.

3 participants