Skip to content

array_slice doesn't convert array<int, mixed> to list #12880

Closed
phpstan/phpstan-src
#3946
@Feolius

Description

@Feolius

Bug report

In array_slice docs it is said

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.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions