Skip to content

Types are wrong for array_splice #11917

@stof

Description

@stof

Bug report

array_splice has 2 issues:

  • it does not preserve the list status of an array passed as argument when inserting new elements in the array, while PHP returns a list in that case: https://3v4l.org/TdJpn
  • it keeps the key type as a union of literal integers, while inserting new elements will add new keys in the array, which won't match that union

Code snippet that reproduces the problem

https://phpstan.org/r/cfd4bca9-57fb-4181-8c8a-f0b6d8823ebb

Expected output

No error reported for that code (not counting the type debugging of course)

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

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions