%s(): never-returning function must not implicitly return¶
Description¶
A function with the never return type must return anything. This means no return keyword, but also, no possibility to reach the end of the method, as it would trigger automatically a return null;.
Example¶
<?php
function foo(): never {
if (true) {
throw new Exception('bad');
}
}
foo();
?>
Literal Examples¶
foo(): never-returning function must not implicitly return
Solutions¶
Add a
dieat the end of the method.Add a
throwat the end of the method.
In more recent PHP versions, this error message is now %s(): never-returning %s must not implicitly return.