You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
array_slice() will reorder and reset the integer array indices by default. This behaviour can be changed by setting preserve_keys to true.
So, if preserve_keys flag is set to false (default) and array has integer keys then result of array_slice must be a list.
In the code snippet I used array_unique function to get array<int<0, max>, mixed>. After passing result to array_slice with no preserve_keys flags set, I expect no errors.
this is more complex than that, when you account for arrays where the key type is inferred as a subtype of int (for instance 12|15|16).
This is kinda related to #11917
Bug report
In array_slice docs it is said
So, if preserve_keys flag is set to false (default) and array has integer keys then result of array_slice must be a list.
In the code snippet I used array_unique function to get array<int<0, max>, mixed>. After passing result to array_slice with no preserve_keys flags set, I expect no errors.
Code snippet that reproduces the problem
https://phpstan.org/r/95d7c1ee-199e-4ba8-9940-40c0c932d290
Expected output
No errors must be reported
Did PHPStan help you today? Did it make you happy in any way?
Yes, it helps a LOT. Thanks for all your work.
The text was updated successfully, but these errors were encountered: