Skip to content

date: Correctly handle Duration::__construct() calls - #23098

Merged
TimWolla merged 1 commit into
php:masterfrom
TimWolla:time-duration-reflection-invoke-construct
Aug 7, 2026
Merged

date: Correctly handle Duration::__construct() calls#23098
TimWolla merged 1 commit into
php:masterfrom
TimWolla:time-duration-reflection-invoke-construct

Conversation

@TimWolla

@TimWolla TimWolla commented Aug 7, 2026

Copy link
Copy Markdown
Member

No description provided.

@TimWolla
TimWolla requested a review from ndossche August 7, 2026 11:05
@TimWolla
TimWolla requested a review from derickr as a code owner August 7, 2026 11:05
TimWolla referenced this pull request Aug 7, 2026
* date: Add `Time\Duration`

RFC: https://wiki.php.net/rfc/duration_class

* date: Cache the most recently `Time\Duration` object created with `from*()`

This is useful for patterns like the following:

    for (;;) {
        $watchers = $poll->wait(Time\Duration::fromSeconds(1));
        // …
    }

which is repeatedly creating identical duration objects for every loop
iteration.

* date: Add `Z_PARAM_ULONG()` helper to `time_duration.c`

* date: Make `tests/time/duration/helper.inc` compatible with PHP < 8.6

This will allow polyfills to more easily consume the upstream tests.

* NEWS / UPGRADING

Co-authored-by: Tim Düsterhus <tim@bastelstu.be>
Co-authored-by: Nora Dossche <7771979+ndossche@users.noreply.github.com>
@TimWolla
TimWolla force-pushed the time-duration-reflection-invoke-construct branch from af4b5e3 to 0a3b1ae Compare August 7, 2026 11:11

@Girgias Girgias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that also works.

@TimWolla
TimWolla merged commit d229653 into php:master Aug 7, 2026
18 checks passed
@TimWolla
TimWolla deleted the time-duration-reflection-invoke-construct branch August 7, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants