diff --git a/language/oop5/properties.xml b/language/oop5/properties.xml index 106df043e945..66a33330977b 100644 --- a/language/oop5/properties.xml +++ b/language/oop5/properties.xml @@ -330,6 +330,36 @@ $test->obj = new stdClass; + + As of PHP 8.3.0, readonly properties can be reinitialized when cloning an object + using the __clone() method. + + Readonly properties and cloning + +prop = null; + } + + public function setProp(string $prop): void { + $this->prop = $prop; + } +} + +$test1 = new Test1; +$test1->setProp('foobar'); + +$test2 = clone $test1; +var_dump($test2->prop); // NULL +?> +]]> + + +