Skip to content

Commit

Permalink
unit => singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
kamil-tekiela committed Jan 15, 2025
1 parent 0704534 commit f72cd60
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion language/types.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ int(16)
&language.types.void;
&language.types.never;
&language.types.relative-class-types;
&language.types.unit;
&language.types.singleton;
&language.types.iterable;
&language.types.declarations;
&language.types.type-juggling;
Expand Down
2 changes: 1 addition & 1 deletion language/types/declarations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ Stack trace:
<title>Union types</title>
<warning>
<simpara>
It is not possible to combine the two unit types <type>false</type>
It is not possible to combine the two singleton types <type>false</type>
and <type>true</type> together in a union type.
Use <type>bool</type> instead.
</simpara>
Expand Down
9 changes: 8 additions & 1 deletion language/types/type-system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
</listitem>
<listitem>
<simpara>
<link linkend="language.types.unit">Unit types</link>
<link linkend="language.types.unit">Singleton types</link>
</simpara>
<itemizedlist>
<listitem>
Expand All @@ -78,6 +78,13 @@
<listitem>
<simpara><type>true</type></simpara>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<simpara>
<link linkend="language.types.unit">Unit types</link>
</simpara>
<itemizedlist>
<listitem>
<simpara><type>null</type></simpara>
</listitem>
Expand Down
16 changes: 8 additions & 8 deletions language/types/unit.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<sect1 xml:id="language.types.unit">
<title>Unit types</title>
<sect1 xml:id="language.types.singleton">
<title>Singleton types</title>

<para>
Unit types are those which allow only one value.
PHP has support for three unit types:
<type>false</type> as of PHP 8.0.0, <type>true</type>
as of PHP 8.2.0, and <type>null</type>.
Singleton types are those which allow only one value.
PHP has support for two singleton types:
<type>false</type> as of PHP 8.0.0 and <type>true</type>
as of PHP 8.2.0.
</para>

<warning>
<simpara>
Prior to PHP 8.2.0 the <type>false</type> and <type>null</type> type
Prior to PHP 8.2.0 the <type>false</type> type
could only be used as part of a
<link linkend="language.types.type-system.composite.union">union type</link>.
</simpara>
</warning>

<note>
<simpara>
It is not possible to define custom unit types. Consider using an
It is not possible to define custom singleton types. Consider using an
<link linkend="language.types.enumerations">enumerations</link> instead.
</simpara>
</note>
Expand Down

0 comments on commit f72cd60

Please sign in to comment.