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
Incomplete return type for mb_split() function #7421
Comments
I found these snippets: https://psalm.dev/r/0b69779c9f<?php
$text = 'Hello world!';
$split = mb_split(' ', $text);
if ($split === false) {
// Do something
}
|
Do you have a code that would actually make mb_split returns false? Sometimes, when we're sure Psalm will catch every case that would make a function errors, we allow ourselves to not include the error return for better inference, but I'm not sure this is the case here... |
@orklah I spent a minute looking at that a couple hours ago because I had the same thought, there's one case that probably shouldn't happen, but there are also 2 valid cases: https://3v4l.org/dN6pD https://psalm.dev/r/57fd317561 |
Cool, thanks for confirmation. @ryanhobrock you correctly identified what needed to change. Small caveat, you need to change this in CallMap and CallMap_historical. Can you push a PR? |
@orklah I would to raise PR for these changes, can you please assign me |
With pleasure :) |
Hey @orklah in which directory can i Find the files CallMap and CallMap_historical as you said the changes are to be made in this 2 files? |
Just right here: https://github.com/vimeo/psalm/tree/4.x/dictionaries |
@orklah cool ! I found it , Thanks a lot , will be generating a PR soon |
Thank you @orklah, @AndrolGenhald, and @RishiKumarRay for the quick work on this! |
Function
mb_split()
should have a return type ofarray|false
per the PHP documentation. The Psalm call maps only havearray
leading to aTypeDoesNotContainType
"list<string> does not contain false" error when type checking. See https://psalm.dev/r/0b69779c9f to reproduce the issue.Changing the call maps from:
to:
should resolve it.
The text was updated successfully, but these errors were encountered: