Readonly classes in PHP 8.2

1 · Amit Merchant · April 29, 2022, 10:22 a.m.
When readonly properties were introduced in PHP 8.1, it has provided a legitimate way of making class properties truly “readonly”. Readonly properties Readonly classes [RFC] Untyped and static properties are restricted Only readonly class can inherit other readonly class In closing Readonly properties Before that, developers used to replicate this behavior by making the intended property private so that it kind of becomes “readonly”. Here’s an example. class Book { private $author; ...