-
Notifications
You must be signed in to change notification settings - Fork 484
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
Better typing for mb_convert_encoding #3749
base: 2.1.x
Are you sure you want to change the base?
Better typing for mb_convert_encoding #3749
Conversation
e514bc3
to
6f121ae
Compare
@@ -6312,7 +6312,7 @@ | |||
'mb_check_encoding' => ['bool', 'var='=>'string|array<string>', 'encoding='=>'string'], | |||
'mb_chr' => ['string|false', 'cp'=>'int', 'encoding='=>'string'], | |||
'mb_convert_case' => ['string', 'sourcestring'=>'string', 'mode'=>'int', 'encoding='=>'string'], | |||
'mb_convert_encoding' => ['string|array<int, string>|false', 'val'=>'string|array<int, string>', 'to_encoding'=>'string', 'from_encoding='=>'mixed'], | |||
'mb_convert_encoding' => ['string|array<scalar|null|array<scalar|null>>|false', 'val'=>'string|array<scalar|null|array<scalar|null>>', 'to_encoding'=>'string', 'from_encoding='=>'mixed'], |
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.
Is there a way to represent a recursive type?
Or is only going 3 layers deep good enough?
7004ae4
to
8a95b77
Compare
8a95b77
to
daee21d
Compare
4f4c8f5
to
026cb29
Compare
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.
It's possible to produce a false return value, for instance with
mb_convert_encoding("\x80\x81\x82", "UTF-8", 'auto')
So I'm unsure about changing the Union to a BenevolentUnion.
People should be advised to add a false
check on the result.
@@ -1,10 +0,0 @@ | |||
<?php // lint < 8.0 |
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.
Existing bug are generally not removed but updated. (to see the diff)
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.
reverted delete
ef98d62
to
1f7fe1c
Compare
Closes phpstan/phpstan#12309
Also, fixed types related to the array input and output; the output array has the exact same shape as the input array: https://3v4l.org/OrdDb