From 9109661d021d388d498bb9d75b49420e8f8578db Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Fri, 11 Nov 2022 14:58:58 +0000 Subject: [PATCH 1/2] Update trait docs for PHP-8.2 The docs for traits probably need a good overhaul --- language/oop5/traits.xml | 62 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/language/oop5/traits.xml b/language/oop5/traits.xml index 20c4bbcfcf04..29584fdff552 100644 --- a/language/oop5/traits.xml +++ b/language/oop5/traits.xml @@ -466,8 +466,8 @@ $example->x; If a trait defines a property then a class can not define a property with - the same name unless it is compatible (same visibility and initial value), - otherwise a fatal error is issued. + the same name unless it is compatible (same visibility and type, + readonly marker, and initial value), otherwise a fatal error is issued. Conflict Resolution @@ -476,13 +476,17 @@ $example->x; ]]> @@ -490,6 +494,56 @@ class PropertiesExample { + + Constants + + Traits can, as of PHP 8.2.0, also define constants. + + + Defining Constants + + +]]> + + + + If a trait defines a constants then a class can not define a constants with + the same name unless it is compatible (same visibility, initial value, and + finality), otherwise a fatal error is issued. + + + Conflict Resolution + + +]]> + + + +