-
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
Conversation
@@ -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 {} |
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 like mktime($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.
It's the difference between "at which second" and "how many seconds".
Aha, I see now! I wouldn't have noticed this difference.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
I was about to suggest the usage of $max_connections
instead of $backlog
, but found out it's an stablished term. What a pity ^^
ext/sockets/sockets.stub.php
Outdated
|
||
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 {} |
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.
function socket_wsaprotocol_info_export(Socket $socket, int $target_pid): string|false {} | |
function socket_wsaprotocol_info_export(Socket $socket, int $target_process_id): string|false {} |
function socket_wsaprotocol_info_export(Socket $socket, int $target_pid): string|false {} | |
function socket_wsaprotocol_info_export(Socket $socket, int $target_pid): string|false {} |
/** @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 comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering before if our $length
and $max_length
usages are really consistent. E.g. the manual says here Up to len bytes will be fetched from remote host
so it seems it could also be $max_length
.
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've been wondering about this as well. I think it might make sense to make all of these use just $length
, unless they have some non-standard meaning (e.g. in the zlib case, where "max length" refers to a limit on the decoded payload size).
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 think it might make sense to make all of these use just $length
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 comment
The 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:
ext/zlib/zlib.stub.php:function zlib_decode(string $data, int $max_length = 0): string|false {}
ext/zlib/zlib.stub.php:function gzinflate(string $data, int $max_length = 0): string|false {}
ext/zlib/zlib.stub.php:function gzdecode(string $data, int $max_length = 0): string|false {}
ext/zlib/zlib.stub.php:function gzuncompress(string $data, int $max_length = 0): string|false {}
No description provided.