Re: [RFC] Duration class

From: Date: Sat, 20 Jun 2026 15:50:32 +0000
Subject: Re: [RFC] Duration class
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-131431@lists.php.net to get a copy of this message
On Fri, Jun 19, 2026 at 7:15 PM Marc B. <marc@mabe.berlin> wrote: > > > Omg, I wrote in a wrong way - sorry. > I mean the RFC just mentions "The Time\Duration class will also implement > internal “comparison handlers”, which means that direct comparisons with > operators such as < will work". > So there are no other operators defined but there are methods defined for > it. I would expect these defined as operators as well. > > Actually, for the division, there are two use cases but the method > supports only one. > 6s / 2 = 3s > 6s / 2s = 3 > > Hi Tim and Marc I would go with two methods if possible : Duration::countOf(Duration $duration): int; // which would act a bit like intdiv Duration::remainder(Duration $duration): Duration; // which would return the remainder as a Duration instance But that's just a thought. Also why are there some restrictions on the factor argument of divideBy and multiplyBy to only accept positive integers ? At least that is what I understood when I quickly checked the proof of concept. Since Duration are signed instances that restriction seems strange ? Best regards, Ignace

« previous php.internals (#131431) next »