phpstan icon indicating copy to clipboard operation
phpstan copied to clipboard

numeric-string as array key gets coerced to int

Open jlherren opened this issue 1 year ago • 1 comments

Bug report

When a numeric-string is coerced into an array key, it is converted to an int. See corresponding code.

However, that is only correct when the string represents an integer value, but not when it represents a fractional value. See examples on 3v4l. I suppose returning int|numeric-string from that method would be the way to go. But fixing this breaks some tests that were explicitly written for this very case, see issue 4671. So I wanted to report it first.

Code snippet that reproduces the problem

https://phpstan.org/r/4d6b8d09-f07f-45d8-af69-84e5c1e9c273

Expected output

No error.

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

No response

jlherren avatar Aug 28 '23 17:08 jlherren

This is duplicate of #8592.

mvorisek avatar Feb 14 '24 10:02 mvorisek

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Jul 01 '24 01:07 github-actions[bot]