Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use "unit type" instead of "value type" #4332

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.value;
&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 value 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
15 changes: 8 additions & 7 deletions language/types/value.xml → language/types/singleton.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<sect1 xml:id="language.types.value">
<title>Value types</title>
<sect1 xml:id="language.types.singleton">
<title>Singleton types</title>

<para>
Value types are those which not only check the type of a value but also
the value itself. PHP has support for two value types:
<type>false</type> as of PHP 8.0.0, and <type>true</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> type could only be used as part of a
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 value 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
31 changes: 19 additions & 12 deletions language/types/type-system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
<listitem>
<simpara>Built-in types</simpara>
<itemizedlist>
<listitem>
<simpara><type>null</type> type</simpara>
</listitem>
<listitem>
<simpara>
Scalar types:
Expand Down Expand Up @@ -70,18 +67,28 @@
<type>self</type>, <type>parent</type>, and <type>static</type>
</simpara>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<simpara>
<link linkend="language.types.value">Value types</link>
</simpara>
<itemizedlist>
<listitem>
<simpara><type>false</type></simpara>
<simpara>
<link linkend="language.types.singleton">Singleton types</link>
</simpara>
<itemizedlist>
<listitem>
<simpara><type>false</type></simpara>
</listitem>
<listitem>
<simpara><type>true</type></simpara>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<simpara><type>true</type></simpara>
<simpara>
Unit types
</simpara>
<itemizedlist>
<listitem>
<simpara><type>null</type></simpara>
</listitem>
</itemizedlist>
</listitem>
</itemizedlist>
</listitem>
Expand Down
Loading