Bug report
Maybe i am missing some detail, but i think this code shouldn't report a type mismatch:
/**
* @template T of int|null
* @phpstan-param T $b
* @phpstan-return int|T
*/
function a(?int $b): ?int
{
if ($b === null) {
return $b; // phpstan reports: Function a() should return int|(T of int|null) but returns T.
}
return $b;
}
Code snippet that reproduces the problem
https://phpstan.org/r/fbce81ec-7a7c-46e0-afb0-44d01d9e69b5
Expected output
Expected: no type error
Did PHPStan help you today? Did it make you happy in any way?
No response