To ensure the class property will never be modified/changed by itself or children or external calls we can now use a readonly
prefix to class property declaration like so: public readonly string $propertyName = 'thisValueWillNeverChange;
. The only place when we could override the readonly variable is inside the class constructor.
class property
PHP 8.1 – Multi Classes Types
Combine two or more types of classes (or array
) to be required by the class property, local variable or a return type of the function.