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 keys are not always set #3126

Closed
BackEndTea opened this issue Mar 26, 2020 · 3 comments
Closed

Array keys are not always set #3126

BackEndTea opened this issue Mar 26, 2020 · 3 comments
Labels
Milestone

Comments

@BackEndTea
Copy link
Contributor

Bug report

When doing an isset before setting a key in an array phpstan will think the key is always set, but only if a 'child' array is set within that

Code snippet that reproduces the problem

https://phpstan.org/r/f66b9fc9-d92f-4a7e-aa1b-34483e6cf92c

Expected output

I'd expect both functions to not have any errors, but the first function has a failure.

@ondrejmirtes
Copy link
Member

Thank you. This bug has been haunting me for some time, but I've never seen it formulated in a minimized example.

@phpstan-bot
Copy link
Contributor

@BackEndTea After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-10: Strict comparison using === between true and false will always evaluate to false.
+No errors

@github-actions
Copy link

github-actions bot commented Mar 4, 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 Mar 4, 2022
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

3 participants