Re: [RFC] [Vote] Readonly amendments
| From: | Deleu | Date: | Tue, 24 Jan 2023 17:58:05 +0000 |
| Subject: | Re: [RFC] [Vote] Readonly amendments | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-119421@lists.php.net to get a copy of this message | ||
> >
> > Mocking
> >
>
> This isn't a terribly compelling argument. Readonly classes are typically
> value objects; it's rare that you will mock them as they will be used as
> messages or results, and you'll end up doing assertions against them — not
> mocking them.
>
> Anything else it would enable?
If like me you have a lot of service-style classes with recursive autowired
DI, making them all readonly is a no-brainer and mocking some of them
sometimes make sense. I have no opinion in favor or against, but wanted to
point out that to me value objects are less likely to be readonly than
service classes, where mocking are common.