Re: [RFC] Duration class
| From: | Tim Düsterhus | Date: | Tue, 23 Jun 2026 08:01:22 +0000 |
| Subject: | Re: [RFC] Duration class | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-131497@lists.php.net to get a copy of this message | ||
Hi
Am 2026-06-23 02:36, schrieb Peter Stalman:
1. Are there other classes planned for the \Time namespace? I think we
Yes, see also the “Future Scope” section.
should avoid using root namespaces and instead decide on a common namespace, so something likeThe use of the namespace is in line with the namespace policy that you can find at https://github.com/php/policies/blob/main/coding-standards-and-naming.rst#namespaces. It was (almost) unanimously accepted in 2021: https://wiki.php.net/rfc/namespaces_in_bundled_extensions. This policy has been the basis of Random\* (8.2), Dom\* (8.4), Uri\* (8.5).\Std\Timeor\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 aIt's a value object, there is only one reasonable implementation that preserves all the invariants that users expect. This topic has previously also been discussed as part of the URI extension (somewhere here: https://news-web.php.net/php.internals/123997). Best regards Tim DüsterhusDurationInterfaceand 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\Carbonextends\DateTimeand implements\DateTimeInterface.