Add documentation about the never type (#889)

This commit is contained in:
George Peter Banyard 2021-09-23 13:59:21 +01:00 committed by GitHub
parent ed6de1ae20
commit 975e9114e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -513,6 +513,22 @@ function foo(): X|Y {} // Allowed (redundancy is only known at runtime)
</para>
</sect3>
<sect3 xml:id="language.types.declarations.never">
<title>never</title>
<para>
<literal>never</literal> is a return type indicating the function does not
return. This means that it either calls <function>exit</function>, throws
an exception, or is an infinite loop.
Therefore it cannot be part of a union type declaration.
Available as of PHP 8.1.0.
</para>
<para>
<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
return type during inheritance.
</para>
</sect3>
<sect3 xml:id="language.types.declarations.static">
<title>static</title>
<para>