-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Update ext/sockets parameter names #6276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ final class AddressInfo | |
{ | ||
} | ||
|
||
function socket_select(?array &$read_fds, ?array &$write_fds, ?array &$except_fds, ?int $tv_sec, int $tv_usec = 0): int|false {} | ||
function socket_select(?array &$read, ?array &$write, ?array &$except, ?int $seconds, int $microseconds = 0): int|false {} | ||
|
||
function socket_create_listen(int $port, int $backlog = 128): Socket|false {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was about to suggest the usage of |
||
|
||
|
@@ -24,65 +24,65 @@ function socket_listen(Socket $socket, int $backlog = 0): bool {} | |
|
||
function socket_close(Socket $socket): void {} | ||
|
||
function socket_write(Socket $socket, string $buf, ?int $length = null): int|false {} | ||
function socket_write(Socket $socket, string $data, ?int $length = null): int|false {} | ||
|
||
function socket_read(Socket $socket, int $length, int $type = PHP_BINARY_READ): string|false {} | ||
function socket_read(Socket $socket, int $length, int $mode = PHP_BINARY_READ): string|false {} | ||
|
||
/** | ||
* @param string $addr | ||
* @param string $address | ||
* @param int $port | ||
*/ | ||
function socket_getsockname(Socket $socket, &$addr, &$port = null): bool {} | ||
function socket_getsockname(Socket $socket, &$address, &$port = null): bool {} | ||
|
||
/** | ||
* @param string $addr | ||
* @param string $address | ||
* @param int $port | ||
*/ | ||
function socket_getpeername(Socket $socket, &$addr, &$port = null): bool {} | ||
function socket_getpeername(Socket $socket, &$address, &$port = null): bool {} | ||
|
||
function socket_create(int $domain, int $type, int $protocol): Socket|false {} | ||
|
||
function socket_connect(Socket $socket, string $addr, ?int $port = null): bool {} | ||
function socket_connect(Socket $socket, string $address, ?int $port = null): bool {} | ||
|
||
function socket_strerror(int $errno): string {} | ||
function socket_strerror(int $error_code): string {} | ||
|
||
function socket_bind(Socket $socket, string $addr, int $port = 0): bool {} | ||
function socket_bind(Socket $socket, string $address, int $port = 0): bool {} | ||
|
||
/** @param string|null $buf */ | ||
function socket_recv(Socket $socket, &$buf, int $len, int $flags): int|false {} | ||
/** @param string|null $data */ | ||
function socket_recv(Socket $socket, &$data, int $length, int $flags): int|false {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was wondering before if our There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've been wondering about this as well. I think it might make sense to make all of these use just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, it's what I also thought about proposing before, but I wasn't sure if it's the preferable thing to do. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've done this now. Everything uses just $length now, apart from zlib uncompression:
|
||
|
||
function socket_send(Socket $socket, string $buf, int $len, int $flags): int|false {} | ||
function socket_send(Socket $socket, string $data, int $length, int $flags): int|false {} | ||
|
||
/** | ||
* @param string $buf | ||
* @param string $name | ||
* @param string $data | ||
* @param string $address | ||
* @param int $port | ||
*/ | ||
function socket_recvfrom(Socket $socket, &$buf, int $len, int $flags, &$name, &$port = null): int|false {} | ||
function socket_recvfrom(Socket $socket, &$data, int $length, int $flags, &$address, &$port = null): int|false {} | ||
|
||
function socket_sendto(Socket $socket, string $buf, int $len, int $flags, string $addr, ?int $port = null): int|false {} | ||
function socket_sendto(Socket $socket, string $data, int $length, int $flags, string $address, ?int $port = null): int|false {} | ||
|
||
function socket_get_option(Socket $socket, int $level, int $optname): array|int|false {} | ||
function socket_get_option(Socket $socket, int $level, int $option): array|int|false {} | ||
|
||
/** @alias socket_get_option */ | ||
function socket_getopt(Socket $socket, int $level, int $optname): array|int|false {} | ||
function socket_getopt(Socket $socket, int $level, int $option): array|int|false {} | ||
|
||
/** @param array|string|int $optval */ | ||
function socket_set_option(Socket $socket, int $level, int $optname, $optval): bool {} | ||
/** @param array|string|int $value */ | ||
function socket_set_option(Socket $socket, int $level, int $option, $value): bool {} | ||
|
||
/** | ||
* @param array|string|int $optval | ||
* @param array|string|int $value | ||
* @alias socket_set_option | ||
*/ | ||
function socket_setopt(Socket $socket, int $level, int $optname, $optval): bool {} | ||
function socket_setopt(Socket $socket, int $level, int $option, $value): bool {} | ||
|
||
#ifdef HAVE_SOCKETPAIR | ||
/** @param array $fd */ | ||
function socket_create_pair(int $domain, int $type, int $protocol, &$fd): ?bool {} | ||
/** @param array $pair */ | ||
function socket_create_pair(int $domain, int $type, int $protocol, &$pair): ?bool {} | ||
#endif | ||
|
||
#ifdef HAVE_SHUTDOWN | ||
function socket_shutdown(Socket $socket, int $how = 2): bool {} | ||
function socket_shutdown(Socket $socket, int $mode = 2): bool {} | ||
#endif | ||
|
||
function socket_last_error(?Socket $socket = null): int {} | ||
|
@@ -95,22 +95,22 @@ function socket_import_stream($stream): Socket|false {} | |
/** @return resource|false */ | ||
function socket_export_stream(Socket $socket) {} | ||
|
||
function socket_sendmsg(Socket $socket, array $msghdr, int $flags = 0): int|false {} | ||
function socket_sendmsg(Socket $socket, array $message, int $flags = 0): int|false {} | ||
|
||
function socket_recvmsg(Socket $socket, array &$msghdr, int $flags = 0): int|false {} | ||
function socket_recvmsg(Socket $socket, array &$message, int $flags = 0): int|false {} | ||
|
||
function socket_cmsg_space(int $level, int $type, int $n = 0): ?int {} | ||
function socket_cmsg_space(int $level, int $type, int $num = 0): ?int {} | ||
|
||
function socket_addrinfo_lookup(string $host, ?string $service = null, array $hints = []): array|false {} | ||
|
||
function socket_addrinfo_connect(AddressInfo $addr): Socket|false {} | ||
function socket_addrinfo_connect(AddressInfo $address): Socket|false {} | ||
|
||
function socket_addrinfo_bind(AddressInfo $addr): Socket|false {} | ||
function socket_addrinfo_bind(AddressInfo $address): Socket|false {} | ||
|
||
function socket_addrinfo_explain(AddressInfo $addr): array {} | ||
function socket_addrinfo_explain(AddressInfo $address): array {} | ||
|
||
#ifdef PHP_WIN32 | ||
function socket_wsaprotocol_info_export(Socket $socket, int $target_pid): string|false {} | ||
function socket_wsaprotocol_info_export(Socket $socket, int $process_id): string|false {} | ||
|
||
function socket_wsaprotocol_info_import(string $info_id): Socket|false {} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,9 +34,6 @@ var_dump($retval_3 === $options); | |
socket_close($socket); | ||
?> | ||
--EXPECT-- | ||
socket_set_option(): Argument #4 ($optval) must have key "sec" | ||
socket_set_option(): Argument #4 ($value) must have key "sec" | ||
bool(true) | ||
bool(true) | ||
--CREDITS-- | ||
Moritz Neuhaeuser, [email protected] | ||
PHP Testfest Berlin 2009-05-10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ext/date uses
$second
(and$microseconds
), so we should syncronize these. I'd naturally use$seconds
too, but I have no idea about the best solution (e.g.$hours
sounds bad).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the relevant difference between the ext/date usage and other usages is that ext/date uses
$second
in something likemktime($hour, $minute, $second, $day, $month, $year)
, where a point in time is assembled from components. In this case, using the singular makes sense. Outside ext/date,$seconds
is generally used to describe a time interval for a timeout, in which case the plural makes sense. It's the difference between "at which second" and "how many seconds".There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I digged into the Python manual for inspiration again, and found that they always use the plural form: https://docs.python.org/3/library/datetime.html#timedelta-objects So probably
$hours
is not that bad :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha, I see now! I wouldn't have noticed this difference.