On Thu, Jun 18, 2026, 06:49 Tim Düsterhus <[email protected]> wrote:
> Hi > > Derick and I are proposing the introduction of a new `Time\Duration` > class to represent “stop-watch” or “egg-timer” durations to improve the > developer experience for APIs taking a timeout. We are specifically > targeting PHP 8.6 for this RFC, since part of the motivation is > improving the API of the new “Polling API” that already landed in PHP > 8.6 (https://wiki.php.net/rfc/poll_api) before the “backwards > compatibility” door closes with the feature freeze in two months. > > This RFC is also intended to be a first part of a modernized date and > time API in PHP, while being useful on its own. To that extent and given > the deadline we hope to make, the proposed API is intentionally minimal > and focused on functionality that we are relatively certain to: > > 1. Be correct, or > 2. be requirement for future additions that cannot later be added > without breaking compatibility. > > We would therefore ask to keep the discussion focused on actual issues > rather than additional “convenience functionality” that might require > extensive discussion or thought. > > All that said, you can find the RFC at: > https://wiki.php.net/rfc/duration_class. It hopefully includes all the > important explanation and also provides a rationale as to why we made > the design decisions we made. > > Best regards > Tim Düsterhus > Hi Tim and Derick, I like where you're going with this, but I have a couple of notes: 1. Are there other classes planned for the `\Time` namespace? I think we should avoid using root namespaces and instead decide on a common namespace, so something like `\Std\Time` or `\Php\Time`. Although I realized that topic is a bit above this particular RFC, but worth considering for internals as more root namespaces are added. 2. Since the class is marked final (why?), I would recommend we also create a `DurationInterface` and use _that_ as the type wherever it is used. This would alleviate some of the concerns people have with making it final. For example, see popular packages like `\Carbon\Carbon` extends `\DateTime` and implements `\DateTimeInterface`. Thanks, Peter
