$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';
}
Parameter #1 $val of function takesStr expects string, mixed|null given.