Set readonly Properties Outside The Class

PHP 8.1 readonly properties cannot be set from global space, but they can be forced from the host class, just like accessing private properties.

It doesn’t work outside the host class : not in global space, not in a derived class.

Besides that, readonly act as usual : it is only possible to assign the property once.

../_images/readonly_and_private.png