phpstan
phpstan copied to clipboard
numeric-string as array key gets coerced to int
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
This is duplicate of #8592.
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.