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
<?phpabstractclass Base {
/** * @return iterable<int, stdClass> */abstractfunctionreturnsIterable(): iterable;
}
class PsalmCatchesIssue extends Base {
functionreturnsIterable(): iterable {
return [1, 2];
}
}
class PsalmFailsToCatchIssue extends Base {
functionreturnsIterable(): array { // only diff is arrayreturn [3, 4];
}
}
class PsalmCatchesReturnTypeMismatch extends Base {
/** @return array<int, int> */functionreturnsIterable(): array {
return [5, 6];
}
}
Psalm output (using commit a9b5291):
ERROR: InvalidReturnStatement - 13:15 - The inferred type 'list{1, 2}' does not match the declared return type 'iterable<int, stdClass>' for PsalmCatchesIssue::returnsIterable
ERROR: InvalidReturnType - 12:32 - The declared return type 'iterable<int, stdClass>' for PsalmCatchesIssue::returnsIterable is incorrect, got 'list{1, 2}'
ERROR: ImplementedReturnTypeMismatch - 24:16 - The inherited return type 'iterable<int, stdClass>' for Base::returnsIterable is different to the implemented return type for PsalmCatchesReturnTypeMismatch::returnsiterable 'array<int, int>'
https://psalm.dev/r/584b550264
The text was updated successfully, but these errors were encountered: