-
Notifications
You must be signed in to change notification settings - Fork 666
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
Psalm thinks explode() can return false #5347
Labels
Comments
I found these snippets: https://psalm.dev/r/96ef362b30<?php
/**
* @return non-empty-list<string>
*/
function takesAString(string $value) : array {
assert($value !== '');
return explode(',', $value);
}
foreach(takesAString('h,i') as $entry) {
echo $entry;
}
|
Actually it returns false when separator is empty. |
I found these snippets: https://psalm.dev/r/6b3a3e88a6<?php
/** @param non-empty-string $sep */
function f(string $sep): void {
$list = explode($sep, "asd");
if (false === $list) {} // expected: TypeDoesNotContainType: non-empty-list<string> does not contain false
}
|
weirdan
added a commit
to weirdan/psalm
that referenced
this issue
Mar 8, 2021
Fixes vimeo#5347 `explode()` now omits `false` from the return type when separator is a definitely non-empty string.
Ah, u're right. I had delimiter in constant as |
muglug
pushed a commit
that referenced
this issue
Mar 11, 2021
Fixes #5347 `explode()` now omits `false` from the return type when separator is a definitely non-empty string.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have enabled
ignoreInternalFunctionFalseReturn="false"
(I cannot do it in playground) https://psalm.dev/r/96ef362b30
explode()
returns false when value is empty string.I asserted the value is not empty string but psalm still reports it can return false
The text was updated successfully, but these errors were encountered: