Re: [PHP-DEV] [RFC] Duration class
[email protected] (Tim Düsterhus) Tue, 07 Jul 2026 08:57:44 +0200
| Newsgroups | php.internals |
|---|---|
| Message-ID | <[email protected]> |
Hi On 2026-07-04 04:45, Nick Sdot wrote: > Alright, I earlier wasn't sure if you actually wanted to make the class > readonly. I have a gut feeling that making the class readonly could > backfire. I know you consider `Duration` an VO, but with all the > methods that are likely coming who knows? Making all current properties > readonly results in the same as making the class readonly; maybe it is > worth not making the class itself readonly for the time being? Given that the class is also `final`, the `readonly` property on the class can be added and removed without a breaking change [1]. Never say never, but since Duration is a value-object there also won't be additional properties in the future, because existing code might not anticipate them and mishandle Duration objects that make use of the new properties. That's why it was important to include support for negative Durations right away. Best regards Tim Düsterhus [1] Except that `readonly` also disallows dynamic properties, but those will be disallowed either way (that's the `strict-properties` in the stub).