From 9512f65759259cb3767f7c783266de941ef321f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 7 Aug 2026 14:22:23 +0200 Subject: [PATCH] standard: Fix error reporting for negative timeouts in `Io\Poll\Context::wait()` --- ext/standard/io_poll.c | 2 +- ext/standard/tests/poll/poll_ctx_wait.phpt | 24 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 ext/standard/tests/poll/poll_ctx_wait.phpt diff --git a/ext/standard/io_poll.c b/ext/standard/io_poll.c index c29ccfee04f2..f57813874d52 100644 --- a/ext/standard/io_poll.c +++ b/ext/standard/io_poll.c @@ -791,7 +791,7 @@ PHP_METHOD(Io_Poll_Context, wait) struct timespec timeout_ts; if (timeout) { if (timeout->duration.negative) { - zend_argument_value_error(2, "must not be negative"); + zend_argument_value_error(1, "must not be negative"); RETURN_THROWS(); } diff --git a/ext/standard/tests/poll/poll_ctx_wait.phpt b/ext/standard/tests/poll/poll_ctx_wait.phpt new file mode 100644 index 000000000000..5080c1421fdb --- /dev/null +++ b/ext/standard/tests/poll/poll_ctx_wait.phpt @@ -0,0 +1,24 @@ +--TEST-- +Io\Poll\Context::wait(): Parameter validation +--FILE-- +wait(timeout: Time\Duration::fromSeconds(1)->negate()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + $poll_ctx->wait(maxEvents: -1); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +ValueError: Io\Poll\Context::wait(): Argument #1 ($timeout) must not be negative +ValueError: Io\Poll\Context::wait(): Argument #2 ($maxEvents) must be greater than 0