Bug report
The following code produces a fatal error at runtime:
$nullable = $_GET['x'] ?? null;
echo takesStr($nullable); // Fatal error: Uncaught TypeError: Argument 1 passed to takesStr() must be of the type string, null given
function takesStr(string $val): string {
return $val . 'foo';
}
However, PHPStan fails to detect the error, even at level 9 with strict rules: https://phpstan.org/r/b37b1718-1336-47ea-a42b-dd405f34f56d
Psalm detects the error as expected: https://psalm.dev/r/f6dc4527da
Expected output
Parameter #1 $val of function takesStr expects string, mixed|null given.
Actual output