Skip to content

Array key not reconized as int|string #11390

@sentientDebugger

Description

@sentientDebugger

Bug report

Given that an array's keys can only (natively) be int|string, I would have expected numeric-string to be understood as an array-key or int|string when used as an array's keys and/or when trying to access an array's value using a numeric-string as the offset.

Code snippet that reproduces the problem

https://phpstan.org/r/1cdf1f0e-b232-40c3-9a0f-f0b4a7007e1c

Expected output

No errors. I would have also expected the value to be returned by \PHPStan\dumpType($tagsById) to be array<int|string, array{id: numeric-string, tagName: string}>.

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

PHPStan is wonderful! I've found it brings a lot more stability and safety to PHP code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions