Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/standard/io_poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
24 changes: 24 additions & 0 deletions ext/standard/tests/poll/poll_ctx_wait.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--TEST--
Io\Poll\Context::wait(): Parameter validation
--FILE--
<?php
require_once __DIR__ . '/poll.inc';

$poll_ctx = new Io\Poll\Context();

try {
$poll_ctx->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
Loading