although it is often nice to write logic in shorthand, I would personally never sacrifice readability over brevity.
private function getFoo(array $s): string {
if (isset($s['HTTP_X_FORWARDED_HOST'])) {
return $s['HTTP_X_FORWARDED_HOST'];
}
if (isset($s['HTTP_HOST'])) {
return $s['HTTP_HOST'];
}
return $s['SERVER_NAME'];
}
can also be slightly shorter by doing using the null coalescing operator
private function getFoo(array $s): string {
if (isset($s['HTTP_X_FORWARDED_HOST'])) {
return $s['HTTP_X_FORWARDED_HOST'];
}
return $s['HTTP_HOST'] ?? $s['SERVER_NAME'];
}
if you do insist on doing the shorthand version, tnavidi's answer is the way to go