A never-returning %s must not return

Description

A function that never returns, aka, with the never return type, must not use the return statement.

In fact, it must use either throw, die, exit, or call another function that never returns.

This applies to methods, static methods, and any variant of closure.

The runtime-equivalent of this error is never-returning function must not implicitly return.

Example

<?php

function foo() : never {
     return 1;
}

?>

Literal Examples

  • A never-returning function must not return.

Solutions

  • Remove the never return type.

  • Remove the return call.