From 070453480f85f6da664974114cab3b84b8580e26 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Sat, 21 Dec 2024 02:29:30 +0000 Subject: [PATCH 1/2] Use "unit type" instead of "value type" --- language/types.xml | 2 +- language/types/declarations.xml | 2 +- language/types/type-system.xml | 28 +++++++++++++------------- language/types/{value.xml => unit.xml} | 17 ++++++++-------- 4 files changed, 25 insertions(+), 24 deletions(-) rename language/types/{value.xml => unit.xml} (64%) diff --git a/language/types.xml b/language/types.xml index 656ad32dd4d3..24e397f309d7 100644 --- a/language/types.xml +++ b/language/types.xml @@ -131,7 +131,7 @@ int(16) &language.types.void; &language.types.never; &language.types.relative-class-types; - &language.types.value; + &language.types.unit; &language.types.iterable; &language.types.declarations; &language.types.type-juggling; diff --git a/language/types/declarations.xml b/language/types/declarations.xml index 0a4baf140692..fd3b9d589a43 100644 --- a/language/types/declarations.xml +++ b/language/types/declarations.xml @@ -271,7 +271,7 @@ Stack trace: Union types - It is not possible to combine the two value types false + It is not possible to combine the two unit types false and true together in a union type. Use bool instead. diff --git a/language/types/type-system.xml b/language/types/type-system.xml index e71f3be231c0..fd7ad8b6eca7 100644 --- a/language/types/type-system.xml +++ b/language/types/type-system.xml @@ -27,9 +27,6 @@ Built-in types - - null type - Scalar types: @@ -70,18 +67,21 @@ self, parent, and static - - - - - Value types - - - - false - - true + + Unit types + + + + false + + + true + + + null + + diff --git a/language/types/value.xml b/language/types/unit.xml similarity index 64% rename from language/types/value.xml rename to language/types/unit.xml index 643bbe12525d..c6a067d60882 100644 --- a/language/types/value.xml +++ b/language/types/unit.xml @@ -1,24 +1,25 @@ - - Value types + + Unit types - 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: - false as of PHP 8.0.0, and true - as of PHP 8.2.0. + Unit types are those which allow only one value. + PHP has support for three unit types: + false as of PHP 8.0.0, true + as of PHP 8.2.0, and null. - Prior to PHP 8.2.0 the false type could only be used as part of a + Prior to PHP 8.2.0 the false and null type + could only be used as part of a union type. - It is not possible to define custom value types. Consider using an + It is not possible to define custom unit types. Consider using an enumerations instead. From 2c50802dcb09d24e7985e460d87ea8eb9c83a5a7 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Wed, 15 Jan 2025 15:58:00 +0000 Subject: [PATCH 2/2] unit => singleton --- language/types.xml | 2 +- language/types/declarations.xml | 2 +- language/types/{unit.xml => singleton.xml} | 16 ++++++++-------- language/types/type-system.xml | 9 ++++++++- 4 files changed, 18 insertions(+), 11 deletions(-) rename language/types/{unit.xml => singleton.xml} (67%) diff --git a/language/types.xml b/language/types.xml index 24e397f309d7..14483ea5ce0a 100644 --- a/language/types.xml +++ b/language/types.xml @@ -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; diff --git a/language/types/declarations.xml b/language/types/declarations.xml index fd3b9d589a43..4d63b80c95f1 100644 --- a/language/types/declarations.xml +++ b/language/types/declarations.xml @@ -271,7 +271,7 @@ Stack trace: Union types - It is not possible to combine the two unit types false + It is not possible to combine the two singleton types false and true together in a union type. Use bool instead. diff --git a/language/types/unit.xml b/language/types/singleton.xml similarity index 67% rename from language/types/unit.xml rename to language/types/singleton.xml index c6a067d60882..97d7cb5e35b9 100644 --- a/language/types/unit.xml +++ b/language/types/singleton.xml @@ -1,17 +1,17 @@ - - Unit types + + Singleton types - Unit types are those which allow only one value. - PHP has support for three unit types: - false as of PHP 8.0.0, true - as of PHP 8.2.0, and null. + Singleton types are those which allow only one value. + PHP has support for two singleton types: + false as of PHP 8.0.0 and true + as of PHP 8.2.0. - Prior to PHP 8.2.0 the false and null type + Prior to PHP 8.2.0 the false type could only be used as part of a union type. @@ -19,7 +19,7 @@ - It is not possible to define custom unit types. Consider using an + It is not possible to define custom singleton types. Consider using an enumerations instead. diff --git a/language/types/type-system.xml b/language/types/type-system.xml index fd7ad8b6eca7..2bac2d22809a 100644 --- a/language/types/type-system.xml +++ b/language/types/type-system.xml @@ -69,7 +69,7 @@ - Unit types + Singleton types @@ -78,6 +78,13 @@ true + + + + + Unit types + + null