New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incremented numeric-string should change to int/float #2797
Conversation
* @param numeric-string $ns | ||
*/ | ||
function doFoo(string $s, $ns, float $f) { | ||
assertType('string', ++$s); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++$s
will be an int even if the input value is a string. https://3v4l.org/i4rru
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great catch, thx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please have another look, I think it should look better now
This pull request has been marked as ready for review. |
I have tested locally that the error in phpstan/phpstan#10187 no longer happens as requested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add regression test for 10187.
@@ -102,7 +102,7 @@ | |||
'str_ends_with' => ['bool', 'haystack'=>'string', 'needle'=>'string'], | |||
'str_starts_with' => ['bool', 'haystack'=>'string', 'needle'=>'string'], | |||
'strchr' => ['string|false', 'haystack'=>'string', 'needle'=>'string', 'before_needle='=>'bool'], | |||
'stripos' => ['int|false', 'haystack'=>'string', 'needle'=>'string', 'offset='=>'int'], | |||
'stripos' => ['0|positive-int|false', 'haystack'=>'string', 'needle'=>'string', 'offset='=>'int'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to have the same return type across php versions, so we don't need to ignore different errors per php version
took me a few attempts to get this work across php versions.. but it should work now |
This pull request has been marked as ready for review. |
Thank you. |
closes phpstan/phpstan#10122
closes phpstan/phpstan#10187
https://3v4l.org/7J17g