diff --git a/language/oop5/basic.xml b/language/oop5/basic.xml index f497db134d98..edb9b26a8cba 100644 --- a/language/oop5/basic.xml +++ b/language/oop5/basic.xml @@ -125,6 +125,72 @@ Stack trace: + + + Readonly classes + + As of PHP 8.2.0, a class can be marked with the + readonly modifier. + Marking a class as readonly will add the + readonly modifier + to every declared property, and prevent the creation of + dynamic properties. + Moreover, it is impossible to add support for them by using the + AllowDynamicProperties attribute. Attempting to do so + will trigger a compile-time error. + + + + +]]> + + + + + As neither untyped, nor static properties can be marked with the + readonly modifier, readonly classes cannot declare + them either: + + + + +]]> + + + +]]> + + + + A readonly class can be + extended + if, and only if, the child class is also a + readonly class. + +