Re: [RFC] Duration class

From: Date: Tue, 07 Jul 2026 06:57:44 +0000
Subject: Re: [RFC] Duration class
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16  Groups: php.internals 
Request: Send a blank email to internals+get-131786@lists.php.net to get a copy of this message
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).

« previous php.internals (#131786) next »