You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionpossiblyNull(): string|null
{
return random_int(0, 1) ? "x" : null;
}
$data = [
'a' => possiblyNull(),
'b' => possiblyNull(),
'c' => possiblyNull(),
];
if (!$data['a'] || !$data['b']) {
thrownewException("a or b is null");
} elseif (!$data['c']) {
thrownewException("c is null");
}
echo strlen($data['a']);
Expected: no error
Actual result:
ERROR: MixedArgument - test.php:20:13 - Argument 1 of strlen cannot be mixed, expecting string
If I remove the elseif condition, the error goes away. E.g. there is no error with the following identical logic using if instead of elseif:
if (!$data['a'] || !$data['b']) {
thrownewException("a or b is null");
}
if (!$data['c']) {
thrownewException("c is null");
}
This bug seems specific to the 4.x branch (I reproduced with v4.27 and the latest commit on the 4.x branch, but couldn't reproduce with dev-master or on https://psalm.dev/).
The text was updated successfully, but these errors were encountered:
Can you also reproduce it on an oldest version of Psalm?
If this is a recent regression, it may not be merged on master yet. If this is something that was fixed on master, I fear this won't ever be on 4.x. There was a lot of change made on master that can't be put back in current version.
Reproduction:
Expected: no error
Actual result:
If I remove the
elseif
condition, the error goes away. E.g. there is no error with the following identical logic usingif
instead ofelseif
:This bug seems specific to the 4.x branch (I reproduced with v4.27 and the latest commit on the 4.x branch, but couldn't reproduce with dev-master or on https://psalm.dev/).
The text was updated successfully, but these errors were encountered: