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
<?php/** * @template T as int|false * @param T $value * @return int */functionfalseDoesntWork($value) {
if ($value === false) {
return -1;
}
return$value;
}
/** * @template T as int|null * @param T $value * @return int */functionbutNullDoes($value) {
if ($value === null) {
return -1;
}
return$value;
}
Psalm output (using commit ba63ccb):
ERROR: DocblockTypeContradiction - 9:9 - T does not contain false
ERROR: FalsableReturnStatement - 12:12 - The declared return type 'int' for falseDoesntWork does not allow false, but the function returns 'T'
ERROR: InvalidFalsableReturnType - 6:12 - The declared return type 'int' for falseDoesntWork does not allow false, but 'T|int' contains false
I think both examples here should pass, but only the one with
null
does:https://psalm.dev/r/ad857f2e4b
The text was updated successfully, but these errors were encountered: