Re: [PHP-DEV] [RFC] Duration class

[email protected] (Tim Düsterhus) Mon, 13 Jul 2026 16:22:58 +0200
Newsgroups php.internals
Message-ID <[email protected]>
Hi

On 2026-07-08 02:49, Pierre Joye wrote:
>> > If injectivity were the real goal, none of Java, Rust, or Temporal
>> > would be usable APIs by that standard, they're explicitly
>> > non-injective by design, and that hasn't stopped them from being the
>> > reference implementations you're citing as inspiration.
>> 
>> Yes, *inspiration*. We looked at those to see how others approach the
>> problem, but of course built our own list of requirements and/or goals
>> based on constraints imposed by PHP and also based on our experience 
>> of
>> working with dates and times both in PHP and other programming
>> languages.
> 
> I wonder, what are the constraints php has for this proposal? And how
> PHP doing something different than almost any other language is the
> result of these constraints?

Lack of method overloading would be one thing, see also: 
https://news-web.php.net/php.internals/131391.

As for the specific case of “the constructors should be injective 
functions”, you missed the second half of the quoted sentence: “and also 
based on our experience of working with dates and times both in PHP and 
other programming languages”, although native support for fixed-point 
decimals would certainly made the API nicer.

Best regards
Tim Düsterhus