]> granicus.if.org Git - php/commitdiff
Use UNKNOWN default for socket_connect()
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 14 Apr 2020 13:16:28 +0000 (15:16 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 14 Apr 2020 14:09:01 +0000 (16:09 +0200)
Specifying the port is mandatory for INET sockets.

ext/sockets/sockets.stub.php
ext/sockets/sockets_arginfo.h

index 5fe5b1cf7347f4fbd61fcd527d7b96ee2d30249a..680a1b883559fb5ee06d7a2156dfb9073d225908 100644 (file)
@@ -41,7 +41,7 @@ function socket_getpeername($socket, &$addr, &$port = UNKNOWN): bool {}
 function socket_create(int $domain, int $type, int $protocol) {}
 
 /** @param resource $socket */
-function socket_connect($socket, string $addr, int $port = 0): bool {}
+function socket_connect($socket, string $addr, int $port = UNKNOWN): bool {}
 
 function socket_strerror(int $errno): string {}
 
index 929ad012290600a744f02bb1b61c2b627eb9220d..3c8e91d0ec2db04fd7f726488854b699cd6a8ab4 100644 (file)
@@ -61,14 +61,18 @@ ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_socket_connect, 0, 2, _IS_BOOL, 0)
        ZEND_ARG_INFO(0, socket)
        ZEND_ARG_TYPE_INFO(0, addr, IS_STRING, 0)
-       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, port, IS_LONG, 0, "0")
+       ZEND_ARG_TYPE_INFO(0, port, IS_LONG, 0)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_socket_strerror, 0, 1, IS_STRING, 0)
        ZEND_ARG_TYPE_INFO(0, errno, IS_LONG, 0)
 ZEND_END_ARG_INFO()
 
-#define arginfo_socket_bind arginfo_socket_connect
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_socket_bind, 0, 2, _IS_BOOL, 0)
+       ZEND_ARG_INFO(0, socket)
+       ZEND_ARG_TYPE_INFO(0, addr, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, port, IS_LONG, 0, "0")
+ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_recv, 0, 4, MAY_BE_LONG|MAY_BE_FALSE)
        ZEND_ARG_INFO(0, socket)