diff options
author | Andrew Dolgov <[email protected]> | 2022-07-12 22:26:21 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2022-07-12 22:26:21 +0300 |
commit | 80d3db1dcf8fe9ca66d4e3f2e2116d3bc39ae2b4 (patch) | |
tree | 04b33bfb9c9368c4a31e287153abec690b9014e0 /vendor/thecodingmachine/safe/generated/sockets.php | |
parent | 4b6161892000cb2b8392dce92a9cf2cabdf2d20e (diff) |
upgrade idiorm to php8.1-patched version (aaronpk/idiorm)
Diffstat (limited to 'vendor/thecodingmachine/safe/generated/sockets.php')
-rw-r--r-- | vendor/thecodingmachine/safe/generated/sockets.php | 224 |
1 files changed, 132 insertions, 92 deletions
diff --git a/vendor/thecodingmachine/safe/generated/sockets.php b/vendor/thecodingmachine/safe/generated/sockets.php index d6cc892b4..bfcd9bac4 100644 --- a/vendor/thecodingmachine/safe/generated/sockets.php +++ b/vendor/thecodingmachine/safe/generated/sockets.php @@ -10,23 +10,23 @@ use Safe\Exceptions\SocketsException; * socket_bind, and told to listen for connections * with socket_listen, this function will accept * incoming connections on that socket. Once a successful connection - * is made, a new socket resource is returned, which may be used - * for communication. If there are multiple connections queued on - * the socket, the first will be used. If there are no pending + * is made, a new Socket instance is returned, + * which may be used for communication. If there are multiple connections + * queued on the socket, the first will be used. If there are no pending * connections, socket_accept will block until * a connection becomes present. If socket * has been made non-blocking using * socket_set_blocking or * socket_set_nonblock, FALSE will be returned. * - * The socket resource returned by + * The Socket instance returned by * socket_accept may not be used to accept new * connections. The original listening socket * socket, however, remains open and may be * reused. * - * @param resource $socket A valid socket resource created with socket_create. - * @return resource Returns a new socket resource on success. The actual + * @param resource $socket A Socket instance created with socket_create. + * @return resource Returns a new Socket instance on success. The actual * error code can be retrieved by calling * socket_last_error. This error code may be passed to * socket_strerror to get a textual explanation of the @@ -46,19 +46,19 @@ function socket_accept($socket) /** - * Create a Socket resource, and bind it to the provided AddrInfo resource. The return + * Create a Socket instance, and bind it to the provided AddressInfo. The return * value of this function may be used with socket_listen. * - * @param resource $addr Resource created from socket_addrinfo_lookup. - * @return resource Returns a Socket resource on success. + * @param resource $address AddressInfo instance created from socket_addrinfo_lookup. + * @return resource|null Returns a Socket instance on success. * @throws SocketsException * */ -function socket_addrinfo_bind($addr) +function socket_addrinfo_bind($address) { error_clear_last(); - $result = \socket_addrinfo_bind($addr); - if ($result === null) { + $result = \socket_addrinfo_bind($address); + if ($result === false) { throw SocketsException::createFromPhpError(); } return $result; @@ -66,19 +66,50 @@ function socket_addrinfo_bind($addr) /** - * Create a Socket resource, and connect it to the provided AddrInfo resource. The return + * Create a Socket instance, and connect it to the provided AddressInfo instance. The return * value of this function may be used with the rest of the socket functions. * - * @param resource $addr Resource created from socket_addrinfo_lookup - * @return resource Returns a Socket resource on success. + * @param resource $address AddressInfo instance created from socket_addrinfo_lookup + * @return resource|null Returns a Socket instance on success. + * @throws SocketsException + * + */ +function socket_addrinfo_connect($address) +{ + error_clear_last(); + $result = \socket_addrinfo_connect($address); + if ($result === false) { + throw SocketsException::createFromPhpError(); + } + return $result; +} + + +/** + * Lookup different ways we can connect to host. The returned array contains + * a set of AddressInfo instances that we can bind to using socket_addrinfo_bind. + * + * @param string $host Hostname to search. + * @param mixed $service The service to connect to. If service is a name, it is translated to the corresponding + * port number. + * @param array $hints Hints provide criteria for selecting addresses returned. You may specify the + * hints as defined by getadrinfo. + * @return resource[] Returns an array of AddressInfo instances that can be used with the other socket_addrinfo functions. + * On failure, FALSE is returned. * @throws SocketsException * */ -function socket_addrinfo_connect($addr) +function socket_addrinfo_lookup(string $host, $service = null, array $hints = []): iterable { error_clear_last(); - $result = \socket_addrinfo_connect($addr); - if ($result === null) { + if ($hints !== []) { + $result = \socket_addrinfo_lookup($host, $service, $hints); + } elseif ($service !== null) { + $result = \socket_addrinfo_lookup($host, $service); + } else { + $result = \socket_addrinfo_lookup($host); + } + if ($result === false) { throw SocketsException::createFromPhpError(); } return $result; @@ -91,7 +122,7 @@ function socket_addrinfo_connect($addr) * a connection is be established using socket_connect * or socket_listen. * - * @param resource $socket A valid socket resource created with socket_create. + * @param resource $socket A Socket instance created with socket_create. * @param string $address If the socket is of the AF_INET family, the * address is an IP in dotted-quad notation * (e.g. 127.0.0.1). @@ -116,11 +147,12 @@ function socket_bind($socket, string $address, int $port = 0): void /** - * Initiate a connection to address using the socket resource - * socket, which must be a valid socket - * resource created with socket_create. + * Initiate a connection to address using the Socket instance + * socket, which must be Socket + * instance created with socket_create. * - * @param resource $socket + * @param resource $socket A Socket instance created with + * socket_create. * @param string $address The address parameter is either an IPv4 address * in dotted-quad notation (e.g. 127.0.0.1) if * socket is AF_INET, a valid @@ -135,10 +167,14 @@ function socket_bind($socket, string $address, int $port = 0): void * @throws SocketsException * */ -function socket_connect($socket, string $address, int $port = 0): void +function socket_connect($socket, string $address, int $port = null): void { error_clear_last(); - $result = \socket_connect($socket, $address, $port); + if ($port !== null) { + $result = \socket_connect($socket, $address, $port); + } else { + $result = \socket_connect($socket, $address); + } if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -146,7 +182,7 @@ function socket_connect($socket, string $address, int $port = 0): void /** - * socket_create_listen creates a new socket resource of + * socket_create_listen creates a new Socket instance of * type AF_INET listening on all * local interfaces on the given port waiting for new connections. * @@ -159,7 +195,7 @@ function socket_connect($socket, string $address, int $port = 0): void * SOMAXCONN may be passed as * backlog parameter, see * socket_listen for more information. - * @return resource socket_create_listen returns a new socket resource + * @return resource socket_create_listen returns a new Socket instance * on success. The error code can be retrieved with * socket_last_error. This code may be passed to * socket_strerror to get a textual explanation of the @@ -180,7 +216,7 @@ function socket_create_listen(int $port, int $backlog = 128) /** * socket_create_pair creates two connected and - * indistinguishable sockets, and stores them in fd. + * indistinguishable sockets, and stores them in pair. * This function is commonly used in IPC (InterProcess Communication). * * @param int $domain The domain parameter specifies the protocol @@ -199,14 +235,14 @@ function socket_create_listen(int $port, int $backlog = 128) * * See socket_create for the full list of supported * protocols. - * @param resource[]|null $fd Reference to an array in which the two socket resources will be inserted. + * @param resource[]|null $pair Reference to an array in which the two Socket instances will be inserted. * @throws SocketsException * */ -function socket_create_pair(int $domain, int $type, int $protocol, ?iterable &$fd): void +function socket_create_pair(int $domain, int $type, int $protocol, ?iterable &$pair): void { error_clear_last(); - $result = \socket_create_pair($domain, $type, $protocol, $fd); + $result = \socket_create_pair($domain, $type, $protocol, $pair); if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -214,7 +250,7 @@ function socket_create_pair(int $domain, int $type, int $protocol, ?iterable &$f /** - * Creates and returns a socket resource, also referred to as an endpoint + * Creates and returns a Socket instance, also referred to as an endpoint * of communication. A typical network connection is made up of 2 sockets, one * performing the role of the client, and another performing the role of the server. * @@ -229,7 +265,7 @@ function socket_create_pair(int $domain, int $type, int $protocol, ?iterable &$f * the desired protocol is TCP, or UDP the corresponding constants * SOL_TCP, and SOL_UDP * can also be used. - * @return resource socket_create returns a socket resource on success. The actual error code can be retrieved by calling + * @return resource socket_create returns a Socket instance on success. The actual error code can be retrieved by calling * socket_last_error. This error code may be passed to * socket_strerror to get a textual explanation of the * error. @@ -268,10 +304,10 @@ function socket_export_stream($socket) /** * The socket_get_option function retrieves the value for - * the option specified by the optname parameter for the + * the option specified by the option parameter for the * specified socket. * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $socket A Socket instance created with socket_create * or socket_accept. * @param int $level The level parameter specifies the protocol * level at which the option resides. For example, to retrieve options at @@ -280,7 +316,7 @@ function socket_export_stream($socket) * TCP, can be used by * specifying the protocol number of that level. Protocol numbers can be * found by using the getprotobyname function. - * @param int $optname Reports whether the socket lingers on + * @param int $option Reports whether the socket lingers on * socket_close if data is present. By default, * when the socket is closed, it attempts to send all unsent data. * In the case of a connection-oriented socket, @@ -298,14 +334,14 @@ function socket_export_stream($socket) * is sent or the time specified in l_linger * elapses. If the socket is non-blocking, * socket_close will fail and return an error. - * @return mixed Returns the value of the given options. + * @return mixed Returns the value of the given option. * @throws SocketsException * */ -function socket_get_option($socket, int $level, int $optname) +function socket_get_option($socket, int $level, int $option) { error_clear_last(); - $result = \socket_get_option($socket, $level, $optname); + $result = \socket_get_option($socket, $level, $option); if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -317,9 +353,9 @@ function socket_get_option($socket, int $level, int $optname) * Queries the remote side of the given socket which may either result in * host/port or in a Unix filesystem path, dependent on its type. * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $socket A Socket instance created with socket_create * or socket_accept. - * @param string $address If the given socket is of type AF_INET or + * @param string|null $address If the given socket is of type AF_INET or * AF_INET6, socket_getpeername * will return the peers (remote) IP address in * appropriate notation (e.g. 127.0.0.1 or @@ -336,7 +372,7 @@ function socket_get_option($socket, int $level, int $optname) * @throws SocketsException * */ -function socket_getpeername($socket, string &$address, ?int &$port = null): void +function socket_getpeername($socket, ?string &$address, ?int &$port = null): void { error_clear_last(); $result = \socket_getpeername($socket, $address, $port); @@ -349,9 +385,9 @@ function socket_getpeername($socket, string &$address, ?int &$port = null): void /** * * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $socket A Socket instance created with socket_create * or socket_accept. - * @param string|null $addr If the given socket is of type AF_INET + * @param string|null $address If the given socket is of type AF_INET * or AF_INET6, socket_getsockname * will return the local IP address in appropriate notation (e.g. * 127.0.0.1 or fe80::1) in the @@ -366,10 +402,10 @@ function socket_getpeername($socket, string &$address, ?int &$port = null): void * @throws SocketsException * */ -function socket_getsockname($socket, ?string &$addr, ?int &$port = null): void +function socket_getsockname($socket, ?string &$address, ?int &$port = null): void { error_clear_last(); - $result = \socket_getsockname($socket, $addr, $port); + $result = \socket_getsockname($socket, $address, $port); if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -380,7 +416,7 @@ function socket_getsockname($socket, ?string &$addr, ?int &$port = null): void * Imports a stream that encapsulates a socket into a socket extension resource. * * @param resource $stream The stream resource to import. - * @return resource|false Returns FALSE. + * @return resource Returns FALSE on failure. * @throws SocketsException * */ @@ -388,7 +424,7 @@ function socket_import_stream($stream) { error_clear_last(); $result = \socket_import_stream($stream); - if ($result === null) { + if ($result === false) { throw SocketsException::createFromPhpError(); } return $result; @@ -405,7 +441,7 @@ function socket_import_stream($stream) * type SOCK_STREAM or * SOCK_SEQPACKET. * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $socket A Socket instance created with socket_create * or socket_addrinfo_bind * @param int $backlog A maximum of backlog incoming connections will be * queued for processing. If a connection request arrives with the queue @@ -434,19 +470,19 @@ function socket_listen($socket, int $backlog = 0): void /** - * The function socket_read reads from the socket - * resource socket created by the + * The function socket_read reads from the Socket instance + * socket created by the * socket_create or * socket_accept functions. * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $socket A Socket instance created with socket_create * or socket_accept. * @param int $length The maximum number of bytes read is specified by the * length parameter. Otherwise you can use * \r, \n, - * or \0 to end reading (depending on the type + * or \0 to end reading (depending on the mode * parameter, see below). - * @param int $type Optional type parameter is a named constant: + * @param int $mode Optional mode parameter is a named constant: * * * @@ -469,10 +505,10 @@ function socket_listen($socket, int $backlog = 0): void * @throws SocketsException * */ -function socket_read($socket, int $length, int $type = PHP_BINARY_READ): string +function socket_read($socket, int $length, int $mode = PHP_BINARY_READ): string { error_clear_last(); - $result = \socket_read($socket, $length, $type); + $result = \socket_read($socket, $length, $mode); if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -482,14 +518,14 @@ function socket_read($socket, int $length, int $type = PHP_BINARY_READ): string /** * The function socket_send sends - * len bytes to the socket - * socket from buf. + * length bytes to the socket + * socket from data. * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $socket A Socket instance created with socket_create * or socket_accept. - * @param string $buf A buffer containing the data that will be sent to the remote host. - * @param int $len The number of bytes that will be sent to the remote host from - * buf. + * @param string $data A buffer containing the data that will be sent to the remote host. + * @param int $length The number of bytes that will be sent to the remote host from + * data. * @param int $flags The value of flags can be any combination of * the following flags, joined with the binary OR (|) * operator. @@ -530,10 +566,10 @@ function socket_read($socket, int $length, int $type = PHP_BINARY_READ): string * @throws SocketsException * */ -function socket_send($socket, string $buf, int $len, int $flags): int +function socket_send($socket, string $data, int $length, int $flags): int { error_clear_last(); - $result = \socket_send($socket, $buf, $len, $flags); + $result = \socket_send($socket, $data, $length, $flags); if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -564,13 +600,13 @@ function socket_sendmsg($socket, array $message, int $flags = 0): int /** * The function socket_sendto sends - * len bytes from buf + * length bytes from data * through the socket socket to the - * port at the address addr. + * port at the address address. * - * @param resource $socket A valid socket resource created using socket_create. - * @param string $buf The sent data will be taken from buffer buf. - * @param int $len len bytes from buf will be + * @param resource $socket A Socket instance created using socket_create. + * @param string $data The sent data will be taken from buffer data. + * @param int $length length bytes from data will be * sent. * @param int $flags The value of flags can be any combination of * the following flags, joined with the binary OR (|) @@ -608,7 +644,7 @@ function socket_sendmsg($socket, array $message, int $flags = 0): int * * * - * @param string $addr IP address of the remote host. + * @param string $address IP address of the remote host. * @param int $port port is the remote port number at which the data * will be sent. * @return int socket_sendto returns the number of bytes sent to the @@ -616,10 +652,14 @@ function socket_sendmsg($socket, array $message, int $flags = 0): int * @throws SocketsException * */ -function socket_sendto($socket, string $buf, int $len, int $flags, string $addr, int $port = 0): int +function socket_sendto($socket, string $data, int $length, int $flags, string $address, int $port = null): int { error_clear_last(); - $result = \socket_sendto($socket, $buf, $len, $flags, $addr, $port); + if ($port !== null) { + $result = \socket_sendto($socket, $data, $length, $flags, $address, $port); + } else { + $result = \socket_sendto($socket, $data, $length, $flags, $address); + } if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -636,7 +676,7 @@ function socket_sendto($socket, string $buf, int $len, int $flags, string $addr, * a blocking socket, the script will pause its execution until it receives * a signal or it can perform the operation. * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $socket A Socket instance created with socket_create * or socket_accept. * @throws SocketsException * @@ -661,7 +701,7 @@ function socket_set_block($socket): void * signal or it can perform the operation. Rather, if the operation would result * in a block, the called function will fail. * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $socket A Socket instance created with socket_create * or socket_accept. * @throws SocketsException * @@ -678,12 +718,12 @@ function socket_set_nonblock($socket): void /** * The socket_set_option function sets the option - * specified by the optname parameter, at the + * specified by the option parameter, at the * specified protocol level, to the value pointed to - * by the optval parameter for the + * by the value parameter for the * socket. * - * @param resource $socket A valid socket resource created with socket_create + * @param resource $socket A Socket instance created with socket_create * or socket_accept. * @param int $level The level parameter specifies the protocol * level at which the option resides. For example, to retrieve options at @@ -692,16 +732,16 @@ function socket_set_nonblock($socket): void * TCP, can be used by specifying the protocol number of that level. * Protocol numbers can be found by using the * getprotobyname function. - * @param int $optname The available socket options are the same as those for the + * @param int $option The available socket options are the same as those for the * socket_get_option function. - * @param int|string|array $optval The option value. + * @param int|string|array $value The option value. * @throws SocketsException * */ -function socket_set_option($socket, int $level, int $optname, $optval): void +function socket_set_option($socket, int $level, int $option, $value): void { error_clear_last(); - $result = \socket_set_option($socket, $level, $optname, $optval); + $result = \socket_set_option($socket, $level, $option, $value); if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -713,10 +753,10 @@ function socket_set_option($socket, int $level, int $optname, $optval): void * incoming, outgoing or all data (the default) from being sent through the * socket * - * @param resource $socket A valid socket resource created with socket_create. - * @param int $how The value of how can be one of the following: + * @param resource $socket A Socket instance created with socket_create. + * @param int $mode The value of mode can be one of the following: * - * possible values for how + * possible values for mode * * * @@ -743,10 +783,10 @@ function socket_set_option($socket, int $level, int $optname, $optval): void * @throws SocketsException * */ -function socket_shutdown($socket, int $how = 2): void +function socket_shutdown($socket, int $mode = 2): void { error_clear_last(); - $result = \socket_shutdown($socket, $how); + $result = \socket_shutdown($socket, $mode); if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -756,18 +796,18 @@ function socket_shutdown($socket, int $how = 2): void /** * Exports the WSAPROTOCOL_INFO structure into shared memory and returns * an identifier to be used with socket_wsaprotocol_info_import. The - * exported ID is only valid for the given target_pid. + * exported ID is only valid for the given process_id. * - * @param resource $socket A valid socket resource. - * @param int $target_pid The ID of the process which will import the socket. + * @param resource $socket A Socket instance. + * @param int $process_id The ID of the process which will import the socket. * @return string Returns an identifier to be used for the import * @throws SocketsException * */ -function socket_wsaprotocol_info_export($socket, int $target_pid): string +function socket_wsaprotocol_info_export($socket, int $process_id): string { error_clear_last(); - $result = \socket_wsaprotocol_info_export($socket, $target_pid); + $result = \socket_wsaprotocol_info_export($socket, $process_id); if ($result === false) { throw SocketsException::createFromPhpError(); } @@ -780,7 +820,7 @@ function socket_wsaprotocol_info_export($socket, int $target_pid): string * * @param string $info_id The ID which has been returned by a former call to * socket_wsaprotocol_info_export. - * @return resource Returns the socket resource + * @return resource Returns a Socket instance on success * @throws SocketsException * */ |