From 7c794e39e8d8a80d17c63a81d7fe6e2ede635dcf Mon Sep 17 00:00:00 2001 From: NickSdot Date: Fri, 7 Aug 2026 15:15:31 +0000 Subject: [PATCH] ext/sockets: applied fixers to improve test robustness --- ext/sockets/tests/gh16267.phpt | 4 +- ext/sockets/tests/gh20532.phpt | 1 - ext/sockets/tests/mcast_ipv4_send_error.phpt | 8 ++-- ext/sockets/tests/mcast_sockettype_error.phpt | 4 +- ext/sockets/tests/socket_addrinfo_lookup.phpt | 4 +- .../tests/socket_bind_invalid_port.phpt | 8 ++-- .../tests/socket_cmsg_udp_segment.phpt | 8 ++-- ext/sockets/tests/socket_connect_params.phpt | 8 ++-- .../socket_create_listen_invalid_port.phpt | 8 ++-- .../tests/socket_create_pair-wrongparams.phpt | 8 ++-- .../tests/socket_create_pair_sockexec.phpt | 12 +++--- ext/sockets/tests/socket_export_stream-2.phpt | 12 +++--- ext/sockets/tests/socket_export_stream-4.phpt | 6 +-- .../tests/socket_getaddrinfo_error.phpt | 40 +++++++++---------- ext/sockets/tests/socket_import_stream-2.phpt | 8 ++-- ext/sockets/tests/socket_import_stream-4.phpt | 6 +-- ext/sockets/tests/socket_reuseport_cbpf.phpt | 2 +- .../tests/socket_select-wrongparams-2.phpt | 4 +- ext/sockets/tests/socket_select_error.phpt | 4 +- ext/sockets/tests/socket_send_params.phpt | 4 +- .../tests/socket_sendto_invalid_port.phpt | 8 ++-- ext/sockets/tests/socket_sendto_params.phpt | 4 +- .../socket_sendto_unix_addr_too_long.phpt | 4 +- .../tests/socket_set_block-retval.phpt | 4 +- .../tests/socket_set_nonblock-retval.phpt | 4 +- .../tests/socket_set_option_mcast_error.phpt | 8 ++-- .../tests/socket_set_option_rcvtimeo.phpt | 4 +- .../tests/socket_set_option_seolinger.phpt | 8 ++-- .../tests/socket_set_option_sndtimeo.phpt | 4 +- .../tests/socket_set_option_timeo_error.phpt | 28 ++++++------- ...socket_setoption_tcpusertimeout_64bit.phpt | 8 ++-- 31 files changed, 121 insertions(+), 122 deletions(-) diff --git a/ext/sockets/tests/gh16267.phpt b/ext/sockets/tests/gh16267.phpt index de3e1b657fbc..3bd65d8121fe 100644 --- a/ext/sockets/tests/gh16267.phpt +++ b/ext/sockets/tests/gh16267.phpt @@ -10,9 +10,9 @@ var_dump(socket_strerror(-2147483648)); try { socket_strerror(2147483648); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECTF-- string(%d) "%S" -socket_strerror(): Argument #1 ($error_code) must be between %i and %d +ValueError: socket_strerror(): Argument #1 ($error_code) must be between %i and %d diff --git a/ext/sockets/tests/gh20532.phpt b/ext/sockets/tests/gh20532.phpt index 360f9e7e11a8..2bec6953dac4 100644 --- a/ext/sockets/tests/gh20532.phpt +++ b/ext/sockets/tests/gh20532.phpt @@ -13,4 +13,3 @@ var_dump(socket_addrinfo_lookup("example.com", "http", ['ai_socktype' => SOCK_RA bool(true) bool(true) bool(true) - diff --git a/ext/sockets/tests/mcast_ipv4_send_error.phpt b/ext/sockets/tests/mcast_ipv4_send_error.phpt index 94148df1c4cb..445b3f658346 100644 --- a/ext/sockets/tests/mcast_ipv4_send_error.phpt +++ b/ext/sockets/tests/mcast_ipv4_send_error.phpt @@ -43,7 +43,7 @@ try { $r = socket_set_option($s, $level, IP_MULTICAST_TTL, 256); var_dump($r); } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } $r = socket_get_option($s, $level, IP_MULTICAST_TTL); var_dump($r); @@ -62,7 +62,7 @@ try { $r = socket_set_option($s, $level, IP_MULTICAST_TTL, -1); var_dump($r); } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } $r = socket_get_option($s, $level, IP_MULTICAST_TTL); var_dump($r); @@ -78,7 +78,7 @@ bool(true) int(0) Setting IP_MULTICAST_TTL with 256 -socket_set_option(): Argument #4 ($value) must be between 0 and 255 +ValueError: socket_set_option(): Argument #4 ($value) must be between 0 and 255 int(1) Setting IP_MULTICAST_TTL with "254" @@ -86,5 +86,5 @@ bool(true) int(254) Setting IP_MULTICAST_TTL with -1 -socket_set_option(): Argument #4 ($value) must be between 0 and 255 +ValueError: socket_set_option(): Argument #4 ($value) must be between 0 and 255 int(254) diff --git a/ext/sockets/tests/mcast_sockettype_error.phpt b/ext/sockets/tests/mcast_sockettype_error.phpt index 56308534ebc4..66995779567b 100644 --- a/ext/sockets/tests/mcast_sockettype_error.phpt +++ b/ext/sockets/tests/mcast_sockettype_error.phpt @@ -23,8 +23,8 @@ try { "interface" => "lo", )); } catch (\ValueError $e) { - echo $e->getMessage(), PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -IP address used in the context of an unexpected type of socket +ValueError: IP address used in the context of an unexpected type of socket diff --git a/ext/sockets/tests/socket_addrinfo_lookup.phpt b/ext/sockets/tests/socket_addrinfo_lookup.phpt index 42745f36978d..0c296850d5c5 100644 --- a/ext/sockets/tests/socket_addrinfo_lookup.phpt +++ b/ext/sockets/tests/socket_addrinfo_lookup.phpt @@ -12,8 +12,8 @@ try { )); var_dump($addrinfo[0]); } catch (\ValueError $e) { - echo $e->getMessage(), \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -socket_addrinfo_lookup(): Argument #3 ($hints) must only contain array keys "ai_flags", "ai_socktype", "ai_protocol", or "ai_family" +ValueError: socket_addrinfo_lookup(): Argument #3 ($hints) must only contain array keys "ai_flags", "ai_socktype", "ai_protocol", or "ai_family" diff --git a/ext/sockets/tests/socket_bind_invalid_port.phpt b/ext/sockets/tests/socket_bind_invalid_port.phpt index b70900f68620..8fe2a076ba2f 100644 --- a/ext/sockets/tests/socket_bind_invalid_port.phpt +++ b/ext/sockets/tests/socket_bind_invalid_port.phpt @@ -9,15 +9,15 @@ sockets try { socket_bind($s_c, '0.0.0.0', -1); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_bind($s_c, '0.0.0.0', 65536); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -socket_bind(): Argument #3 ($port) must be between 0 and 65535 -socket_bind(): Argument #3 ($port) must be between 0 and 65535 +ValueError: socket_bind(): Argument #3 ($port) must be between 0 and 65535 +ValueError: socket_bind(): Argument #3 ($port) must be between 0 and 65535 diff --git a/ext/sockets/tests/socket_cmsg_udp_segment.phpt b/ext/sockets/tests/socket_cmsg_udp_segment.phpt index 38a914066510..b74ced8807b2 100644 --- a/ext/sockets/tests/socket_cmsg_udp_segment.phpt +++ b/ext/sockets/tests/socket_cmsg_udp_segment.phpt @@ -13,14 +13,14 @@ $src = socket_create(AF_UNIX, SOCK_DGRAM, 0); try { socket_setopt($src, SOL_UDP, UDP_SEGMENT, -1); } catch (\ValueError $e) { - echo $e->getMessage(), PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_setopt($src, SOL_UDP, UDP_SEGMENT, 65536); } catch (\ValueError $e) { - echo $e->getMessage(), PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -socket_setopt(): Argument #4 ($value) must be between 0 and 65535 -socket_setopt(): Argument #4 ($value) must be between 0 and 65535 +ValueError: socket_setopt(): Argument #4 ($value) must be between 0 and 65535 +ValueError: socket_setopt(): Argument #4 ($value) must be between 0 and 65535 diff --git a/ext/sockets/tests/socket_connect_params.phpt b/ext/sockets/tests/socket_connect_params.phpt index 683b8e9d919f..64f25d792329 100644 --- a/ext/sockets/tests/socket_connect_params.phpt +++ b/ext/sockets/tests/socket_connect_params.phpt @@ -15,19 +15,19 @@ socket_getsockname($s_c, $addr, $port); try { socket_connect($s_c); } catch (\ArgumentCountError $e) { - echo $e->getMessage() . \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_connect($s_c, '0.0.0.0'); } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } $s_w = socket_connect($s_c, '0.0.0.0', $port); socket_close($s_c); ?> --EXPECTF-- -socket_connect() expects at least 2 arguments, 1 given -socket_connect(): Argument #3 ($port) cannot be null when the socket type is AF_INET +ArgumentCountError: socket_connect() expects at least 2 arguments, 1 given +ValueError: socket_connect(): Argument #3 ($port) cannot be null when the socket type is AF_INET Warning: socket_connect(): unable to connect [%i]: %a in %s on line %d diff --git a/ext/sockets/tests/socket_create_listen_invalid_port.phpt b/ext/sockets/tests/socket_create_listen_invalid_port.phpt index 35182139ee6f..2f360501abda 100644 --- a/ext/sockets/tests/socket_create_listen_invalid_port.phpt +++ b/ext/sockets/tests/socket_create_listen_invalid_port.phpt @@ -9,16 +9,16 @@ var_dump(socket_create_listen(0)); try { socket_create_listen(-1); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_create_listen(65536); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECT-- object(Socket)#1 (0) { } -socket_create_listen(): Argument #1 ($port) must be between 0 and 65535 -socket_create_listen(): Argument #1 ($port) must be between 0 and 65535 +ValueError: socket_create_listen(): Argument #1 ($port) must be between 0 and 65535 +ValueError: socket_create_listen(): Argument #1 ($port) must be between 0 and 65535 diff --git a/ext/sockets/tests/socket_create_pair-wrongparams.phpt b/ext/sockets/tests/socket_create_pair-wrongparams.phpt index 1d0a6540841d..c9c8ae38a222 100644 --- a/ext/sockets/tests/socket_create_pair-wrongparams.phpt +++ b/ext/sockets/tests/socket_create_pair-wrongparams.phpt @@ -16,21 +16,21 @@ var_dump(socket_create_pair(AF_INET, 0, 0, $sockets)); try { var_dump(socket_create_pair(31337, 0, 0, $sockets)); } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { var_dump(socket_create_pair(AF_INET, 31337, 0, $sockets)); } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECTF-- Warning: socket_create_pair(): Unable to create socket pair [%d]: %s %r(not supported|wrong type for socket)%r in %s on line %d bool(false) -socket_create_pair(): Argument #1 ($domain) must be one of AF_UNIX, AF_INET6, or AF_INET -socket_create_pair(): Argument #2 ($type) must be one of SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET, SOCK_RAW, or SOCK_RDM%A +ValueError: socket_create_pair(): Argument #1 ($domain) must be one of AF_UNIX, AF_INET6, or AF_INET +ValueError: socket_create_pair(): Argument #2 ($type) must be one of SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET, SOCK_RAW, or SOCK_RDM%A --CREDITS-- Till Klampaeckel, till@php.net Berlin TestFest 2009 diff --git a/ext/sockets/tests/socket_create_pair_sockexec.phpt b/ext/sockets/tests/socket_create_pair_sockexec.phpt index 5e31b1550340..2dd70aef29c6 100644 --- a/ext/sockets/tests/socket_create_pair_sockexec.phpt +++ b/ext/sockets/tests/socket_create_pair_sockexec.phpt @@ -13,22 +13,22 @@ $sockets = array(); try { socket_create_pair(AF_UNIX, 11 | SOCK_CLOEXEC, 0, $sockets); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_create_pair(AF_UNIX, 11 | SOCK_NONBLOCK, 0, $sockets); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_create_pair(AF_UNIX, 11 | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, $sockets); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } var_dump(socket_create_pair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, $sockets)); ?> --EXPECTF-- -socket_create_pair(): Argument #2 ($type) must be one of SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET, SOCK_RAW, or SOCK_RDM%A -socket_create_pair(): Argument #2 ($type) must be one of SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET, SOCK_RAW, or SOCK_RDM%A -socket_create_pair(): Argument #2 ($type) must be one of SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET, SOCK_RAW, or SOCK_RDM%A +ValueError: socket_create_pair(): Argument #2 ($type) must be one of SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET, SOCK_RAW, or SOCK_RDM%A +ValueError: socket_create_pair(): Argument #2 ($type) must be one of SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET, SOCK_RAW, or SOCK_RDM%A +ValueError: socket_create_pair(): Argument #2 ($type) must be one of SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET, SOCK_RAW, or SOCK_RDM%A bool(true) diff --git a/ext/sockets/tests/socket_export_stream-2.phpt b/ext/sockets/tests/socket_export_stream-2.phpt index 0a83ef485ba8..1c40ac17a0ba 100644 --- a/ext/sockets/tests/socket_export_stream-2.phpt +++ b/ext/sockets/tests/socket_export_stream-2.phpt @@ -8,12 +8,12 @@ sockets try { socket_export_stream(fopen(__FILE__, "rb")); } catch (TypeError $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } try { socket_export_stream(stream_socket_server("udp://127.0.0.1:0", $errno, $errstr, STREAM_SERVER_BIND)); } catch (TypeError $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } $s = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); var_dump($s); @@ -22,15 +22,15 @@ socket_close($s); try { var_dump(socket_export_stream($s)); } catch (Error $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } echo "Done."; ?> --EXPECTF-- -socket_export_stream(): Argument #1 ($socket) must be of type Socket, resource given -socket_export_stream(): Argument #1 ($socket) must be of type Socket, resource given +TypeError: socket_export_stream(): Argument #1 ($socket) must be of type Socket, resource given +TypeError: socket_export_stream(): Argument #1 ($socket) must be of type Socket, resource given object(Socket)#%d (0) { } -socket_export_stream(): Argument #1 ($socket) has already been closed +Error: socket_export_stream(): Argument #1 ($socket) has already been closed Done. diff --git a/ext/sockets/tests/socket_export_stream-4.phpt b/ext/sockets/tests/socket_export_stream-4.phpt index 168671138680..da6608428fa8 100644 --- a/ext/sockets/tests/socket_export_stream-4.phpt +++ b/ext/sockets/tests/socket_export_stream-4.phpt @@ -18,7 +18,7 @@ function test($stream, $sock) { try { print_r(stream_set_blocking($stream, false)); } catch (Error $e) { - echo get_class($e), ": ", $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } echo "\n"; } @@ -27,7 +27,7 @@ function test($stream, $sock) { try { print_r(socket_set_block($sock)); } catch (Error $e) { - echo get_class($e), ": ", $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } echo "\n"; echo "socket_get_option "; @@ -36,7 +36,7 @@ function test($stream, $sock) { $opt = socket_get_option($sock, SOL_SOCKET, SO_TYPE); print_r($opt === SOCK_DGRAM ? "DGRAM" : $opt); } catch (Error $e) { - echo get_class($e), ": ", $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } echo "\n"; } diff --git a/ext/sockets/tests/socket_getaddrinfo_error.phpt b/ext/sockets/tests/socket_getaddrinfo_error.phpt index a2455821e70e..1fa7a2889790 100644 --- a/ext/sockets/tests/socket_getaddrinfo_error.phpt +++ b/ext/sockets/tests/socket_getaddrinfo_error.phpt @@ -12,7 +12,7 @@ try { 'ai_protocol' => 0, )); } catch (\TypeError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_addrinfo_lookup('127.0.0.1', 2000, array( @@ -22,7 +22,7 @@ try { 'ai_protocol' => 0, )); } catch (\TypeError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_addrinfo_lookup('127.0.0.1', 2000, array( @@ -32,7 +32,7 @@ try { 'ai_protocol' => 0, )); } catch (\TypeError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_addrinfo_lookup('127.0.0.1', 2000, array( @@ -42,7 +42,7 @@ try { 'ai_protocol' => new stdClass(), )); } catch (\TypeError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_addrinfo_lookup('127.0.0.1', 2000, array( @@ -52,7 +52,7 @@ try { 'ai_protocol' => 0, )); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_addrinfo_lookup('127.0.0.1', 2000, array( @@ -62,7 +62,7 @@ try { 'ai_protocol' => 0, )); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_addrinfo_lookup('127.0.0.1', 2000, array( @@ -72,7 +72,7 @@ try { 'ai_protocol' => 0, )); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_addrinfo_lookup('127.0.0.1', 2000, array( @@ -82,7 +82,7 @@ try { 'ai_protocol' => PHP_INT_MIN, )); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_addrinfo_lookup('127.0.0.1', 2000, [ @@ -92,7 +92,7 @@ try { 0, ]); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_addrinfo_lookup('127.0.0.1', 2000, array( @@ -102,17 +102,17 @@ try { 0, )); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECTF-- -socket_addrinfo_lookup(): Argument #3 ($hints) "ai_family" key must be of type int, stdClass given -socket_addrinfo_lookup(): Argument #3 ($hints) "ai_socktype" key must be of type int, stdClass given -socket_addrinfo_lookup(): Argument #3 ($hints) "ai_flags" key must be of type int, stdClass given -socket_addrinfo_lookup(): Argument #3 ($hints) "ai_protocol" key must be of type int, stdClass given -socket_addrinfo_lookup(): Argument #3 ($hints) "ai_family" key must be AF_INET%A -socket_addrinfo_lookup(): Argument #3 ($hints) "ai_socktype" key must be between 0 and %d -socket_addrinfo_lookup(): Argument #3 ($hints) "ai_flags" key must be between 0 and %d -socket_addrinfo_lookup(): Argument #3 ($hints) "ai_protocol" key must be between 0 and %d -socket_addrinfo_lookup(): Argument #3 ($hints) must only contain array keys "ai_flags", "ai_socktype", "ai_protocol", or "ai_family" -socket_addrinfo_lookup(): Argument #3 ($hints) must only contain array keys "ai_flags", "ai_socktype", "ai_protocol", or "ai_family" +TypeError: socket_addrinfo_lookup(): Argument #3 ($hints) "ai_family" key must be of type int, stdClass given +TypeError: socket_addrinfo_lookup(): Argument #3 ($hints) "ai_socktype" key must be of type int, stdClass given +TypeError: socket_addrinfo_lookup(): Argument #3 ($hints) "ai_flags" key must be of type int, stdClass given +TypeError: socket_addrinfo_lookup(): Argument #3 ($hints) "ai_protocol" key must be of type int, stdClass given +ValueError: socket_addrinfo_lookup(): Argument #3 ($hints) "ai_family" key must be AF_INET%A +ValueError: socket_addrinfo_lookup(): Argument #3 ($hints) "ai_socktype" key must be between 0 and %d +ValueError: socket_addrinfo_lookup(): Argument #3 ($hints) "ai_flags" key must be between 0 and %d +ValueError: socket_addrinfo_lookup(): Argument #3 ($hints) "ai_protocol" key must be between 0 and %d +ValueError: socket_addrinfo_lookup(): Argument #3 ($hints) must only contain array keys "ai_flags", "ai_socktype", "ai_protocol", or "ai_family" +ValueError: socket_addrinfo_lookup(): Argument #3 ($hints) must only contain array keys "ai_flags", "ai_socktype", "ai_protocol", or "ai_family" diff --git a/ext/sockets/tests/socket_import_stream-2.phpt b/ext/sockets/tests/socket_import_stream-2.phpt index 7d3b492a85e1..cb73fbb9b387 100644 --- a/ext/sockets/tests/socket_import_stream-2.phpt +++ b/ext/sockets/tests/socket_import_stream-2.phpt @@ -9,7 +9,7 @@ var_dump(socket_import_stream(fopen(__FILE__, "rb"))); try { socket_import_stream(socket_create(AF_INET, SOCK_DGRAM, SOL_UDP)); } catch (TypeError $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } $s = stream_socket_server("udp://127.0.0.1:0", $errno, $errstr, STREAM_SERVER_BIND); var_dump($s); @@ -17,7 +17,7 @@ var_dump(fclose($s)); try { socket_import_stream($s); } catch (TypeError $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } echo "Done."; @@ -25,8 +25,8 @@ echo "Done."; --EXPECTF-- Warning: socket_import_stream(): Cannot represent a stream of type STDIO as a Socket Descriptor in %s on line %d bool(false) -socket_import_stream(): Argument #1 ($stream) must be of type resource, Socket given +TypeError: socket_import_stream(): Argument #1 ($stream) must be of type resource, Socket given resource(%d) of type (stream) bool(true) -socket_import_stream(): supplied resource is not a valid stream resource +TypeError: socket_import_stream(): supplied resource is not a valid stream resource Done. diff --git a/ext/sockets/tests/socket_import_stream-4.phpt b/ext/sockets/tests/socket_import_stream-4.phpt index 87ca608b862b..0d94f70bb5fe 100644 --- a/ext/sockets/tests/socket_import_stream-4.phpt +++ b/ext/sockets/tests/socket_import_stream-4.phpt @@ -17,7 +17,7 @@ function test($stream, $sock) { try { print_r(stream_set_blocking($stream, false)); } catch (Error $e) { - echo get_class($e), ": ", $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } echo "\n"; } @@ -26,7 +26,7 @@ function test($stream, $sock) { try { print_r(socket_set_block($sock)); } catch (Error $e) { - echo get_class($e), ": ", $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } echo "\n"; echo "socket_get_option "; @@ -35,7 +35,7 @@ function test($stream, $sock) { $opt = socket_get_option($sock, SOL_SOCKET, SO_TYPE); print_r($opt === SOCK_DGRAM ? "DGRAM" : $opt); } catch (Error $e) { - echo get_class($e), ": ", $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } echo "\n"; } diff --git a/ext/sockets/tests/socket_reuseport_cbpf.phpt b/ext/sockets/tests/socket_reuseport_cbpf.phpt index 2210c4438f00..84b2d31b28bc 100644 --- a/ext/sockets/tests/socket_reuseport_cbpf.phpt +++ b/ext/sockets/tests/socket_reuseport_cbpf.phpt @@ -21,7 +21,7 @@ var_dump(socket_set_option( $socket, SOL_SOCKET, SO_REUSEPORT, true)); try { socket_set_option( $socket, SOL_SOCKET, SO_ATTACH_REUSEPORT_CBPF, array()); } catch (\TypeError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } var_dump(socket_set_option( $socket, SOL_SOCKET, SO_ATTACH_REUSEPORT_CBPF, SKF_AD_CPU)); var_dump(socket_bind($socket, '0.0.0.0')); diff --git a/ext/sockets/tests/socket_select-wrongparams-2.phpt b/ext/sockets/tests/socket_select-wrongparams-2.phpt index f2d3799e7570..7e87ebb9908a 100644 --- a/ext/sockets/tests/socket_select-wrongparams-2.phpt +++ b/ext/sockets/tests/socket_select-wrongparams-2.phpt @@ -12,11 +12,11 @@ $time = 0; try { socket_select($sockets, $write, $except, $time); } catch (ValueError $exception) { - echo $exception->getMessage() . "\n"; + echo $exception::class, ': ', $exception->getMessage(), "\n"; } ?> --EXPECT-- -socket_select(): At least one array argument must be passed +ValueError: socket_select(): At least one array argument must be passed --CREDITS-- Till Klampaeckel, till@php.net Berlin TestFest 2009 diff --git a/ext/sockets/tests/socket_select_error.phpt b/ext/sockets/tests/socket_select_error.phpt index 143351dd427d..a9fc383502cb 100644 --- a/ext/sockets/tests/socket_select_error.phpt +++ b/ext/sockets/tests/socket_select_error.phpt @@ -8,8 +8,8 @@ $r = $w = $e = ['no resource']; try { socket_select($r, $w, $e, 1); } catch (TypeError $ex) { - echo $ex->getMessage(), PHP_EOL; + echo $ex::class, ': ', $ex->getMessage(), PHP_EOL; } ?> --EXPECT-- -socket_select(): Argument #1 ($read) must only have elements of type Socket, string given +TypeError: socket_select(): Argument #1 ($read) must only have elements of type Socket, string given diff --git a/ext/sockets/tests/socket_send_params.phpt b/ext/sockets/tests/socket_send_params.phpt index d6294c490105..0e3b8fed11a3 100644 --- a/ext/sockets/tests/socket_send_params.phpt +++ b/ext/sockets/tests/socket_send_params.phpt @@ -8,9 +8,9 @@ sockets try { $s_w = socket_send($s_c, "foo", -1, MSG_OOB); } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } socket_close($s_c); ?> --EXPECT-- -socket_send(): Argument #3 ($length) must be greater than or equal to 0 +ValueError: socket_send(): Argument #3 ($length) must be greater than or equal to 0 diff --git a/ext/sockets/tests/socket_sendto_invalid_port.phpt b/ext/sockets/tests/socket_sendto_invalid_port.phpt index 9ff81ff5e15b..eb9ee7e2657e 100644 --- a/ext/sockets/tests/socket_sendto_invalid_port.phpt +++ b/ext/sockets/tests/socket_sendto_invalid_port.phpt @@ -8,15 +8,15 @@ sockets try { $s_w = socket_sendto($s_c, "foo", 0, MSG_OOB, '127.0.0.1', 65536); } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { $s_w = socket_sendto($s_c, "foo", 0, MSG_OOB, '127.0.0.1', -1); } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } socket_close($s_c); ?> --EXPECT-- -socket_sendto(): Argument #6 ($port) must be between 0 and 65535 -socket_sendto(): Argument #6 ($port) must be between 0 and 65535 +ValueError: socket_sendto(): Argument #6 ($port) must be between 0 and 65535 +ValueError: socket_sendto(): Argument #6 ($port) must be between 0 and 65535 diff --git a/ext/sockets/tests/socket_sendto_params.phpt b/ext/sockets/tests/socket_sendto_params.phpt index ed805ee9be7d..947da5683902 100644 --- a/ext/sockets/tests/socket_sendto_params.phpt +++ b/ext/sockets/tests/socket_sendto_params.phpt @@ -8,9 +8,9 @@ sockets try { $s_w = socket_sendto($s_c, "foo", -1, MSG_OOB, '127.0.0.1'); } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } socket_close($s_c); ?> --EXPECT-- -socket_sendto(): Argument #3 ($length) must be greater than or equal to 0 +ValueError: socket_sendto(): Argument #3 ($length) must be greater than or equal to 0 diff --git a/ext/sockets/tests/socket_sendto_unix_addr_too_long.phpt b/ext/sockets/tests/socket_sendto_unix_addr_too_long.phpt index f2b62527e337..c29644cdace7 100644 --- a/ext/sockets/tests/socket_sendto_unix_addr_too_long.phpt +++ b/ext/sockets/tests/socket_sendto_unix_addr_too_long.phpt @@ -20,10 +20,10 @@ $long_addr = str_repeat('a', 512); try { socket_sendto($socket, "data", 4, 0, $long_addr); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } socket_close($socket); ?> --EXPECTF-- -socket_sendto(): Argument #5 ($address) must be less than %d +ValueError: socket_sendto(): Argument #5 ($address) must be less than %d diff --git a/ext/sockets/tests/socket_set_block-retval.phpt b/ext/sockets/tests/socket_set_block-retval.phpt index 04f980416835..3ec3c384eb0c 100644 --- a/ext/sockets/tests/socket_set_block-retval.phpt +++ b/ext/sockets/tests/socket_set_block-retval.phpt @@ -14,10 +14,10 @@ socket_close($socket2); try { var_dump(socket_set_block($socket2)); } catch (Error $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- bool(true) -socket_set_block(): Argument #1 ($socket) has already been closed +Error: socket_set_block(): Argument #1 ($socket) has already been closed diff --git a/ext/sockets/tests/socket_set_nonblock-retval.phpt b/ext/sockets/tests/socket_set_nonblock-retval.phpt index b92a75e17c2c..91b9f6fc5ef7 100644 --- a/ext/sockets/tests/socket_set_nonblock-retval.phpt +++ b/ext/sockets/tests/socket_set_nonblock-retval.phpt @@ -14,10 +14,10 @@ socket_close($socket2); try { var_dump(socket_set_nonblock($socket2)); } catch (Error $e) { - echo $e->getMessage(), "\n"; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> --EXPECT-- bool(true) -socket_set_nonblock(): Argument #1 ($socket) has already been closed +Error: socket_set_nonblock(): Argument #1 ($socket) has already been closed diff --git a/ext/sockets/tests/socket_set_option_mcast_error.phpt b/ext/sockets/tests/socket_set_option_mcast_error.phpt index 0d7630fb279c..271635ccc9dc 100644 --- a/ext/sockets/tests/socket_set_option_mcast_error.phpt +++ b/ext/sockets/tests/socket_set_option_mcast_error.phpt @@ -22,15 +22,15 @@ $iwanttoleavenow = true; try { socket_set_option($s, $level, MCAST_LEAVE_GROUP, $iwanttoleavenow); } catch (\TypeError $e) { - echo $e->getMessage(), PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_set_option($s, $level, MCAST_LEAVE_SOURCE_GROUP, $iwanttoleavenow); } catch (\TypeError $e) { - echo $e->getMessage(); + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECT-- -socket_set_option(): Argument #4 ($value) must be of type array when argument #3 ($option) is MCAST_LEAVE_GROUP, true given -socket_set_option(): Argument #4 ($value) must be of type array when argument #3 ($option) is MCAST_LEAVE_SOURCE_GROUP, true given +TypeError: socket_set_option(): Argument #4 ($value) must be of type array when argument #3 ($option) is MCAST_LEAVE_GROUP, true given +TypeError: socket_set_option(): Argument #4 ($value) must be of type array when argument #3 ($option) is MCAST_LEAVE_SOURCE_GROUP, true given diff --git a/ext/sockets/tests/socket_set_option_rcvtimeo.phpt b/ext/sockets/tests/socket_set_option_rcvtimeo.phpt index ef75ee025378..b2dc812433cf 100644 --- a/ext/sockets/tests/socket_set_option_rcvtimeo.phpt +++ b/ext/sockets/tests/socket_set_option_rcvtimeo.phpt @@ -17,7 +17,7 @@ socket_set_block($socket); try { $retval_1 = socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, []); } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } //set/get comparison @@ -30,6 +30,6 @@ var_dump($retval_3 === $options); socket_close($socket); ?> --EXPECT-- -socket_set_option(): Argument #4 ($value) must have key "sec" +ValueError: socket_set_option(): Argument #4 ($value) must have key "sec" bool(true) bool(true) diff --git a/ext/sockets/tests/socket_set_option_seolinger.phpt b/ext/sockets/tests/socket_set_option_seolinger.phpt index 0450c7525099..6e0b94403e97 100644 --- a/ext/sockets/tests/socket_set_option_seolinger.phpt +++ b/ext/sockets/tests/socket_set_option_seolinger.phpt @@ -17,7 +17,7 @@ if (!$socket) { try { $retval_1 = socket_set_option( $socket, SOL_SOCKET, SO_LINGER, []); } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } // set/get comparison @@ -30,7 +30,7 @@ $options_2 = array("l_onoff" => 1); try { var_dump(socket_set_option( $socket, SOL_SOCKET, SO_LINGER, $options_2)); } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } var_dump($retval_2); @@ -41,8 +41,8 @@ var_dump((bool)$retval_3["l_onoff"] === (bool)$options["l_onoff"]); socket_close($socket); ?> --EXPECT-- -socket_set_option(): Argument #4 ($value) must have key "l_onoff" -socket_set_option(): Argument #4 ($value) must have key "l_linger" +ValueError: socket_set_option(): Argument #4 ($value) must have key "l_onoff" +ValueError: socket_set_option(): Argument #4 ($value) must have key "l_linger" bool(true) bool(true) bool(true) diff --git a/ext/sockets/tests/socket_set_option_sndtimeo.phpt b/ext/sockets/tests/socket_set_option_sndtimeo.phpt index e7487f75b05c..ef44439cd89e 100644 --- a/ext/sockets/tests/socket_set_option_sndtimeo.phpt +++ b/ext/sockets/tests/socket_set_option_sndtimeo.phpt @@ -17,7 +17,7 @@ socket_set_block($socket); try { $retval_1 = socket_set_option( $socket, SOL_SOCKET, SO_SNDTIMEO, []); } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } //set/get comparison @@ -30,6 +30,6 @@ var_dump($retval_3 === $options); socket_close($socket); ?> --EXPECT-- -socket_set_option(): Argument #4 ($value) must have key "sec" +ValueError: socket_set_option(): Argument #4 ($value) must have key "sec" bool(true) bool(true) diff --git a/ext/sockets/tests/socket_set_option_timeo_error.phpt b/ext/sockets/tests/socket_set_option_timeo_error.phpt index befdfb095855..3f52136e0e6b 100644 --- a/ext/sockets/tests/socket_set_option_timeo_error.phpt +++ b/ext/sockets/tests/socket_set_option_timeo_error.phpt @@ -18,56 +18,56 @@ $options_6 = array("l_onoff" => "1", "l_linger" => PHP_INT_MAX); try { socket_set_option( $socket, SOL_SOCKET, SO_RCVTIMEO, new stdClass); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_set_option( $socket, SOL_SOCKET, SO_RCVTIMEO, $options_1); } catch (\TypeError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_set_option( $socket, SOL_SOCKET, SO_SNDTIMEO, $options_2); } catch (\TypeError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_set_option( $socket, SOL_SOCKET, SO_RCVTIMEO, "not good"); } catch (\TypeError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_set_option( $socket, SOL_SOCKET, SO_LINGER, "not good neither"); } catch (\TypeError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_set_option( $socket, SOL_SOCKET, SO_LINGER, $options_3); } catch (\TypeError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_set_option( $socket, SOL_SOCKET, SO_LINGER, $options_4); } catch (\TypeError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_set_option( $socket, SOL_SOCKET, SO_LINGER, $options_5); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_set_option( $socket, SOL_SOCKET, SO_LINGER, $options_6); } catch (\ValueError $e) { - echo $e->getMessage() . PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --EXPECTF-- -socket_set_option(): Argument #4 ($value) must have key "sec" +ValueError: socket_set_option(): Argument #4 ($value) must have key "sec" Warning: Object of class stdClass could not be converted to int in %s on line %d -socket_set_option(): Argument #4 ($value) must be of type array when argument #3 ($option) is SO_RCVTIMEO, string given -socket_set_option(): Argument #4 ($value) must be of type array when argument #3 ($option) is SO_LINGER, string given -socket_set_option(): Argument #4 ($value) "l_onoff" must be between 0 and %d -socket_set_option(): Argument #4 ($value) "l_linger" must be between 0 and %d +TypeError: socket_set_option(): Argument #4 ($value) must be of type array when argument #3 ($option) is SO_RCVTIMEO, string given +TypeError: socket_set_option(): Argument #4 ($value) must be of type array when argument #3 ($option) is SO_LINGER, string given +ValueError: socket_set_option(): Argument #4 ($value) "l_onoff" must be between 0 and %d +ValueError: socket_set_option(): Argument #4 ($value) "l_linger" must be between 0 and %d diff --git a/ext/sockets/tests/socket_setoption_tcpusertimeout_64bit.phpt b/ext/sockets/tests/socket_setoption_tcpusertimeout_64bit.phpt index 894a24d2a49b..8c6ab6ac93e7 100644 --- a/ext/sockets/tests/socket_setoption_tcpusertimeout_64bit.phpt +++ b/ext/sockets/tests/socket_setoption_tcpusertimeout_64bit.phpt @@ -18,13 +18,13 @@ socket_set_block($socket); try { socket_setopt($socket, SOL_TCP, TCP_USER_TIMEOUT, -1); } catch (\ValueError $e) { - echo $e->getMessage(), PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } try { socket_setopt($socket, SOL_TCP, TCP_USER_TIMEOUT, PHP_INT_MAX); } catch (\ValueError $e) { - echo $e->getMessage(), PHP_EOL; + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } $timeout = 200; @@ -35,7 +35,7 @@ var_dump($retval_3 === $timeout); socket_close($socket); ?> --EXPECTF-- -socket_setopt(): Argument #4 ($value) must be between 0 and %d -socket_setopt(): Argument #4 ($value) must be between 0 and %d +ValueError: socket_setopt(): Argument #4 ($value) must be between 0 and %d +ValueError: socket_setopt(): Argument #4 ($value) must be between 0 and %d bool(true) bool(true)