[doc-en] master: Document the compile-time and runtime checks for never (#5906)

From: Date: Mon, 05 Oct 2026 07:14:04 +0000
Subject: [doc-en] master: Document the compile-time and runtime checks for never (#5906)
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-23808@lists.php.net to get a copy of this message
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


Thread (1 message)

  • Daniel Pinto via GitHub
« previous php.doc.cvs (#23808) next »