Time\Duration - #23073
Merged
Merged
Conversation
derickr
reviewed
Aug 5, 2026
arnaud-lb
reviewed
Aug 5, 2026
|
|
||
| php_date_time_duration *original = Z_DATE_TIME_DURATION_P(ZEND_THIS); | ||
| php_date_time_duration *additional = php_date_time_duration_from_obj(duration); | ||
| php_date_time_duration *new = Z_DATE_TIME_DURATION_P(return_value); |
Member
There was a problem hiding this comment.
When either original or additional has recount==1, it may be possible to reuse it?
arnaud-lb
reviewed
Aug 5, 2026
TimWolla
force-pushed
the
time-duration
branch
8 times, most recently
from
August 5, 2026 20:09
ebb8107 to
5f203d8
Compare
TimWolla
force-pushed
the
time-duration
branch
2 times, most recently
from
August 5, 2026 20:43
89e45ab to
6390166
Compare
TimWolla
commented
Aug 5, 2026
TimWolla
commented
Aug 5, 2026
TimWolla
commented
Aug 5, 2026
TimWolla
force-pushed
the
time-duration
branch
3 times, most recently
from
August 6, 2026 07:45
1f0ff1f to
9e932e2
Compare
TimWolla
force-pushed
the
time-duration
branch
2 times, most recently
from
August 6, 2026 08:23
95eee76 to
a2a58e7
Compare
nyamsprod
reviewed
Aug 6, 2026
derickr
reviewed
Aug 6, 2026
arnaud-lb
approved these changes
Aug 6, 2026
nicolas-grekas
pushed a commit
to nyamsprod/polyfill
that referenced
this pull request
Aug 7, 2026
Runs the phpt tests of php-src (php/php-src#23073) unmodified against the polyfill, and fixes the divergences that are left: * use the native ZPP wording for the multiplyBy()/divideBy() argument errors, and reject a negative divisor with ValueError instead of DivisionByZeroError * detect the nanoseconds overflow of multiplyBy(), which turned into "TypeError: ... must be of type int, float given" * reject "PT1HS" and "PTS", which the native parser does not accept * validate $nanoseconds before the range of $seconds in fromSeconds() * report the native range error in fromMinutes()/fromHours()/fromMicroseconds()/ fromMilliseconds() and when parsing an ISO-8601 duration * forbid dynamic properties, as the native readonly class does The range and the sign of zero durations are now enforced in a single place, so that no operation can return a Duration that breaks the class invariants. On the test side, the phpt files are byte-identical to php-src, except helper.inc which cannot use the syntax of PHP >= 8.5, and new.phpt which is covered by DurationTest since a userland class cannot reject ReflectionClass::newInstanceWithoutConstructor(). DurationTest now runs on PHP >= 8.6 too, so its expectations are checked against the native class. Also adds the subtree split, moves the classmap entry next to the other 8.6 polyfills and ignores the temporary files written by PhptTest.
…om*()`
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.
This will allow polyfills to more easily consume the upstream tests.
nicolas-grekas
added a commit
to symfony/polyfill
that referenced
this pull request
Aug 7, 2026
This PR was squashed before being merged into the 1.x branch. Discussion ---------- Add Polyfill for Time\Duration class Adds the new `Time\Duration` class added to PHP 8.6. This class is part of the new `Time` extension. - [RFC](https://wiki.php.net/rfc/duration_class) - [PR](php/php-src#23073) Commits ------- a976c45 Add Polyfill for Time\Duration class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RFC: https://wiki.php.net/rfc/duration_class