By preceding the type declaration with a question mark (?), PHP allows returning a null or void value:
function get_thing($thing): ?string { if ( ! empty($thing)) { return $thing; } else { return null; } }