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

Union of optional keyed arrays doesn't mean both keys exists at same time #7143

Open
rajyan opened this issue Apr 28, 2022 · 0 comments
Open
Labels

Comments

@rajyan
Copy link
Contributor

rajyan commented Apr 28, 2022

Bug report

I'm investigating
#4809
#6508
#7000
and splitting them into smaller related issues.

If I union two optional keyed constant arrays array{foo?: string, bar: string}|array{foo: string, bar?: string} PHPStan generalize it as array{foo?: string, bar?: string}&non-empty-array (which I think is a correct and smart behavior) but this make it not report an error on offset access on both optional keys.

Code snippet that reproduces the problem

https://phpstan.org/r/519053c6-5183-449b-91ae-b27661281395

Expected output

Report for maybe not existing offset access in line 8,9,17,18

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

Yes! It' definitely a great tool already, and want to help making it even better!

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

No branches or pull requests

2 participants