Skip to content

Stop numeric array key typecasting #18376

Closed as not planned
Closed as not planned
@kkmuffme

Description

@kkmuffme

Description

Currently, PHP will automatically convert some int-like strings to int when used as array keys.

  1. this can lead to unexpected behavior, depending on the array keys used (since some will get typecast, while others won't, even though both would pass is_numeric())

  2. this adds overhead for type juggling on all array operations, since values need to be type juggled

This has been discussed in #9029

I think it would make sense to create an RFC to stop doing this with PHP 8.5 (I don't have permission, otherwise I would have done that already)

Since most people are unaware that this happens in the first place, the impact would probably not be too big, but it is definitely a breaking change.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      close