PHP 8.1 introduced the 'never' return type to indicate functions that will never return normally, typically because they throw exceptions or call exit/die. The type can only be used as a return type, not for parameters, and cannot be combined with union or intersection types. Functions with 'never' type must not return values explicitly or implicitly, otherwise PHP throws fatal errors. A practical example is the dd() function from Symfony's var-dumper package, which always terminates script execution.
2 Comments
Sort: