-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Description
Bug report
In the following example
https://phpstan.org/r/ec2a3c8e-4b32-443f-81b1-f2ba78836f3e
the array is understood as
Dumped type: array<string, array{foo: string, bar: ''}>
but with strict mode we're getting
https://phpstan.org/r/5a249928-665b-4b87-aff3-9e98b53c7fad
Dumped type: array<string, array{foo: string, bar?: ''}>
we have to update the array to a non-empty-array in order to get the right result
https://phpstan.org/r/0302aab8-0877-413b-9dff-ad41d7a8afcf
Code snippet that reproduces the problem
https://phpstan.org/r/5a249928-665b-4b87-aff3-9e98b53c7fad
Expected output
I expect to get
array<string, array{foo: string, bar: ''}>
even if the array in the foreach is empty.
Because if the array is empty, it's [] and it respect the definition array<string, array{foo: string, bar: ''}>.
This would avoid an error on the following code: https://phpstan.org/r/483aa742-4928-47f0-a0b2-02a07d8a684f
Did PHPStan help you today? Did it make you happy in any way?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels