Author: Daniel Pinto (Cayan)
Committer: GitHub (web-flow)
Pusher: lacatoire
Date: 2026-10-05T09:14:01+02:00
Commit: https://github.com/php/doc-en/commit/18a1cc50345c2d75983290a3863e451da2c2ecb9
Raw diff: https://github.com/php/doc-en/commit/18a1cc50345c2d75983290a3863e451da2c2ecb9.diff
Document the compile-time and runtime checks for never (#5906)
* Document the compile-time and runtime checks for never
* Tag TypeError with exceptionname on the never type page
Changed paths:
M language/types/never.xml
Diff:
diff --git a/language/types/never.xml b/language/types/never.xml
index 2b84103606b7..406d565b1a24 100644
--- a/language/types/never.xml
+++ b/language/types/never.xml
@@ -10,6 +10,13 @@
<link linkend="language.types.type-system.composite.union">union
type</link>
declaration. Available as of PHP 8.1.0.
</para>
+ <simpara>
+ A <literal>return</literal> statement in a <type>never</type> function is
a
+ compile-time error, even if the <literal>return</literal> would not be
+ reached during execution. If control flow reaches the end of a
+ <type>never</type> function without exiting, throwing an exception, or
+ entering an infinite loop, a <exceptionname>TypeError</exceptionname> is thrown.
+ </simpara>
<simpara>
<type>never</type> is, in type theory parlance, the bottom type,
meaning it is the subtype of every other type and can replace any other