PHP8 이전에는 throw는 명령문이므로 화살표 함수, 삼항연산자, 엘비스 연산자(?:)와 같이 표현식만 허용되는 위치에서 예외를 throw 하는 것은 불가능했으나 PHP8에서는 가능해짐
// This was previously not possible since arrow functions only accept a single expression while throw was a statement.
$callable = fn() => throw new Exception();
// $value is non-nullable.
$value = $nullableValue ?? throw new InvalidArgumentException();
// $value is truthy.
$value = $falsableValue ?: throw new InvalidArgumentException();
// $value is only set if the array is not empty.
$value = !empty($array)
? reset($array)
: throw new InvalidArgumentException();