A helper that throws an HTTP exception was typed void, so every caller had to write an unreachable return statement to satisfy the analyser.
// before
function abort(int $status): void
{
throw new HttpException($status);
}
if (! $order) {
abort(404);
return null; // unreachable, and required
}
// after
function abort(int $status): never
{
throw new HttpException($status);
}
if (! $order) {
abort(404); // the analyser knows this is the end
}
never means the function does not return at all — it throws, exits, or loops forever — which is different from returning nothing. The practical gain is that control-flow analysis follows it: an analyser stops complaining about a missing return, and narrowing after the call is correct rather than assumed. A function typed never that does return is a fatal error, which is the right severity.