// *** before: ***
function findUser($id) {
// nothing in the signature says the result can be null
return $id > 0 ? new User($id) : null;
}
// *** in version 7.1: ***
function findUser(int $id): ?User {
return $id > 0 ? new User($id) : null;
}
function greet(?string $name) {
echo 'Hello, ' . ($name ?? 'guest');
}