Skip to content
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

Open
wants to merge 2 commits into
base: 2.1.x
Choose a base branch
from

Conversation

jack-worman
Copy link
Contributor

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

@jack-worman jack-worman force-pushed the mb_convert_encoding-can-return-false branch 2 times, most recently from e514bc3 to 6f121ae Compare December 21, 2024 18:58
@@ -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'],
Copy link
Contributor Author

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?

@jack-worman jack-worman force-pushed the mb_convert_encoding-can-return-false branch from 8f1a5ed to 36caa2c Compare December 22, 2024 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Strict comparison using === between string and false will always evaluate to false.
1 participant