Re: Readonly properties - immutability by default

From: Date: Fri, 16 Jul 2021 10:12:52 +0000
Subject: Re: Readonly properties - immutability by default
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-115438@lists.php.net to get a copy of this message
On Fri, Jul 16, 2021 at 9:45 AM Eugene Sidelnyk <zsidelnik@gmail.com> wrote: > Readonly properties are really useful for DDD, where everything is going to > be immutable. It promotes best practices. However for people to use it, > syntax should be concise and brief. If every property of the class is readonly it would probably be better to declare that with a class modifier. E.g. ```php readonly class Entity { public int $count; public string $data; } ``` Though readonly doesn't look like a perfect fit in that position to me. -- Best regards, Bruce Weirdan mailto:weirdan@gmail.com

« previous php.internals (#115438) next »