Skip to content

standard: Take Time\Duration in Io\Poll\Context::wait() - #23092

Merged
TimWolla merged 1 commit into
php:masterfrom
TimWolla:poll-wait-duration
Aug 7, 2026
Merged

standard: Take Time\Duration in Io\Poll\Context::wait()#23092
TimWolla merged 1 commit into
php:masterfrom
TimWolla:poll-wait-duration

Conversation

@TimWolla

@TimWolla TimWolla commented Aug 6, 2026

Copy link
Copy Markdown
Member

@arnaud-lb arnaud-lb 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.

Looks good to me!

@TimWolla
TimWolla force-pushed the poll-wait-duration branch from 8c7e053 to cb6188d Compare August 7, 2026 10:07
@TimWolla
TimWolla marked this pull request as ready for review August 7, 2026 10:08
@TimWolla
TimWolla merged commit ed2ffe6 into php:master Aug 7, 2026
18 checks passed
@TimWolla
TimWolla deleted the poll-wait-duration branch August 7, 2026 10:48
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()
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.

2 participants