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

PHPStan loses type information after null coalescing on array with 63 or more properties #9397

Closed
RobertoGeuke opened this issue Jun 6, 2023 · 3 comments
Labels
Milestone

Comments

@RobertoGeuke
Copy link

RobertoGeuke commented Jun 6, 2023

Bug report

After null coalescing PHPStan loses type information on all other properties of the array. The new type of those properties becomes a union of all used types in the array (e.g. bool|int|string|null). This error only happens when the array contains 63 or more properties. See snippet for more information.

Code snippet that reproduces the problem

https://phpstan.org/r/9926eff3-05d8-4444-8510-1ed26a8368d1

Expected output

PHPStan should remember the type of all properties in the array, regardless of usage of null coalescing or amount of properties.

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

PHPStan helps us a lot during our daily work 😀

@ondrejmirtes
Copy link
Member

I rewrote the example to be a bit more obvious what's expected there (edited your description).

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Jun 6, 2023
@EmielM
Copy link

EmielM commented Jun 26, 2023

This is currently a blocker for a larger typing project here at Crisp. Is there anything we can do to help out with the "Easy fix", @ondrejmirtes :)? Do you plan on simply increasing some constant that defines this behavior? Thank you!

@ondrejmirtes
Copy link
Member

Fixed phpstan/phpstan-src#3032

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

3 participants