ctype_digit() narrows to decimal-int-string#5311
ctype_digit() narrows to decimal-int-string#5311staabm wants to merge 4 commits intophpstan:2.2.xfrom
Conversation
|
You've opened the pull request against the latest branch 2.2.x. PHPStan 2.2 is not going to be released for months. If your code is relevant on 2.1.x and you want it to be released sooner, please rebase your pull request and change its target to 2.1.x. |
| if (ctype_digit((string) $numericString)) { | ||
| assertType('numeric-string', $numericString); | ||
| } else { | ||
| assertType('*NEVER*', $numericString); |
There was a problem hiding this comment.
bug before PR: numeric strings exist which ctype_digit does not return true, for see https://3v4l.org/1Qrlg#veol
There was a problem hiding this comment.
Should be fix on 2.1 then ?
There was a problem hiding this comment.
Not sure its worth fixing on 2.1.x because noone reported it yet and I think for a good fix we need decimal-int-string type which only exists on 2.2.x
|
I’d put brakes on this a bit. It’s an experimental type, it’s too soon to propagate it around the codebase. |
|
My current idea is that there is going to be 3-way setting about “unsafe array string keys”. The default would be current behaviour (unsafe), to not break users’ baselines with more specific types. |
|
I see. lets park it for now and come back after the array-key topic is more mature. |
I also tried #5312 on my side @ondrejmirtes.
|
|
Yes, |
No description provided.