Skip to content

Bad assumption about array key #12779

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

Closed
hocker1 opened this issue Mar 24, 2025 · 2 comments
Closed

Bad assumption about array key #12779

hocker1 opened this issue Mar 24, 2025 · 2 comments

Comments

@hocker1
Copy link

hocker1 commented Mar 24, 2025

Bug report

PHPstan seems to incorrectly narrow type after if (empty(...)).

Code snippet that reproduces the problem

https://phpstan.org/r/0554aa13-e165-4f18-b512-059cf0ab243e

Expected output

Dumped type should remain array<mixed> even after the if test (which may result false).

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

No response

@hocker1
Copy link
Author

hocker1 commented Mar 24, 2025

Snippet, that demonstrates practical problem caused by the bug and which will be error-free once the bug is solved:
https://phpstan.org/r/5ff9d8fe-dcb7-4dc9-aec1-021c06513f37

@herndlm
Copy link
Contributor

herndlm commented Mar 24, 2025

Hi, looks like a duplicate of #12771, I prepared a fix already in phpstan/phpstan-src#3901

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants