standard: Take Time\Duration in Io\Poll\Context::wait() - #23092
Merged
Conversation
TimWolla
force-pushed
the
poll-wait-duration
branch
from
August 7, 2026 10:07
8c7e053 to
cb6188d
Compare
TimWolla
marked this pull request as ready for review
August 7, 2026 10:08
nicolas-grekas
added a commit
to symfony/polyfill
that referenced
this pull request
Aug 7, 2026
php/php-src#23092 replaced the $timeoutSeconds and $timeoutMicroseconds arguments of Io\Poll\Context::wait() by a single ?Time\Duration $timeout, and both changes ship in 8.6 Beta 1. The vendored phpt files get the same edits as upstream. Time\Duration is not a dependency of the package: the polyfill never builds one, it only reads the components of the instance it is given, and a caller that has an instance necessarily has the class already.
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 ---------- [IoPoll] Take Time\Duration in Context::wait() | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT Depends on #642, on top of which this branch sits — only the last commit belongs here. php/php-src#23092 is merged and ships in 8.6 Beta 1, alongside `Time\Duration`. It replaces the `$timeoutSeconds`/`$timeoutMicroseconds` arguments of `Io\Poll\Context::wait()` by a single `?Time\Duration $timeout`: ```php -public function wait(?int $timeoutSeconds = null, int $timeoutMicroseconds = 0, ?int $maxEvents = null): array +public function wait(?\Time\Duration $timeout = null, ?int $maxEvents = null): array ``` The vendored phpt files get exactly the edits php-src made in that commit: `wait(0)` becomes `wait(Time\Duration::fromSeconds(0))` and `wait(0, 100000)` becomes `wait(Time\Duration::fromMicroseconds(100000))`. Every file that was a byte-identical copy of `ext/standard/tests/poll/` still is; the three that already differed (`poll.inc`, `poll_stream_sock_rw_close.phpt`, `poll_stream_sock_rw_multi_level.phpt`, all stale rather than adapted) keep exactly the differences they had. `symfony/polyfill-time` is deliberately not a dependency: the polyfill never builds a `Duration`, it only reads `->negative`, `->seconds` and `->nanoseconds` off the instance it is handed, and the type declaration is only resolved when a non-null value is passed. Calling `wait()` or `wait(null)` therefore works without it, and a caller that has a `Duration` to pass necessarily has the class already. The component README says where to get it. One divergence worth a decision: native reports the negative-timeout error as argument #2, ```c if (timeout->duration.negative) { zend_argument_value_error(2, "must not be negative"); ``` which looks like a leftover from the old signature, since `$timeout` is argument #1 and #2 is now `$maxEvents`. No phpt covers it. The polyfill reports #1; if upstream keeps #2 I will align. Commits ------- 5d1b0f3 [IoPoll] Take Time\Duration in Context::wait()
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