[RFC] [Discussion] Readonly Classes

From: Date: Mon, 22 Nov 2021 16:13:49 +0000
Subject: [RFC] [Discussion] Readonly Classes
Groups: php.internals 
Request: Send a blank email to internals+get-116472@lists.php.net to get a copy of this message
Hi Internals, I'd like to propose adding support for readonly classes: https://wiki.php.net/rfc/readonly_classes The implementation heavily builds on the semantics of the already accepted readonly properties RFC (https://wiki.php.net/rfc/readonly_properties_v2), basically the only thing I had to implement in the PR are the following: - Any declared property of a readonly class is implicitly treated as readonly - Creation of dynamic properties is forbidden Readonly classes would make it easier to declare immutable(-alike) classes, especially if a class contains a lot of properties. As a side-effect, one could already opt out from dynamic properties completely, which won't really be possible for quite some time, even if https://wiki.php.net/rfc/deprecate_dynamic_properties passes. Regards: Máté

« previous php.internals (#116472) next »