Re: [RFC] Duration class
| From: | ignace nyamagana butera | Date: | Sun, 21 Jun 2026 14:57:38 +0000 |
| Subject: | Re: [RFC] Duration class | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-131439@lists.php.net to get a copy of this message | ||
On Sun, Jun 21, 2026 at 3:57 PM Tim Düsterhus <tim@bastelstu.be> wrote:
> Hi
>
> On 6/21/26 11:18, ignace nyamagana butera wrote:
> > Indeed Duration::divmod is the way forward just wondering about the
> return
> > type. Should it be an array or a immutable DTO with .2 properties
> quotient
> > and remainder?
>
> For bcdivmod it was a deliberate choice to make the result a 2-tuple,
> with the expectation that array destructuring is used to consume the
> return value.
>
> Operation-wise I would agree that “div mod” is the correct thing to do,
> but I don't think that calling Duration/Duration->(int, Duration)
> literally divmod is an intuitive API when there's also the other
> division that does Duration/int->Duration.
>
> Best regards
> Tim Düsterhus
>
Then maybe we could go with chunkedBy or decomposedBy ?
These are just propositions, naming things is hard
Best regards
Ignace