Commit 7a07ce9b80b for php.net

commit 7a07ce9b80bb0b87931ab430d4eba16673c22715
Author: NickSdot <32384907+NickSdot@users.noreply.github.com>
Date:   Sun Sep 6 19:44:16 2026 +0700

    ext/sockets: applied fixers to improve test robustness (#23135)

diff --git a/ext/sockets/tests/gh16267.phpt b/ext/sockets/tests/gh16267.phpt
index de3e1b657fb..f6e18148cff 100644
--- a/ext/sockets/tests/gh16267.phpt
+++ b/ext/sockets/tests/gh16267.phpt
@@ -9,10 +9,10 @@
 var_dump(socket_strerror(-2147483648));
 try {
 	socket_strerror(2147483648);
-} catch (\ValueError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 ?>
 --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 360f9e7e11a..2bec6953dac 100644
--- a/ext/sockets/tests/gh20532.phpt
+++ b/ext/sockets/tests/gh20532.phpt
@@ -13,4 +13,3 @@
 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 94148df1c4c..c19264f0dcc 100644
--- a/ext/sockets/tests/mcast_ipv4_send_error.phpt
+++ b/ext/sockets/tests/mcast_ipv4_send_error.phpt
@@ -42,8 +42,8 @@
 try {
     $r = socket_set_option($s, $level, IP_MULTICAST_TTL, 256);
     var_dump($r);
-} catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+} catch (\Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 $r = socket_get_option($s, $level, IP_MULTICAST_TTL);
 var_dump($r);
@@ -61,8 +61,8 @@
 try {
     $r = socket_set_option($s, $level, IP_MULTICAST_TTL, -1);
     var_dump($r);
-} catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+} catch (\Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 $r = socket_get_option($s, $level, IP_MULTICAST_TTL);
 var_dump($r);
@@ -78,7 +78,7 @@
 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 @@
 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 56308534ebc..7747e743522 100644
--- a/ext/sockets/tests/mcast_sockettype_error.phpt
+++ b/ext/sockets/tests/mcast_sockettype_error.phpt
@@ -22,9 +22,9 @@
         "group"	=> '127.0.0.1',
         "interface" => "lo",
     ));
-} catch (\ValueError $e) {
-	echo $e->getMessage(), PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 ?>
 --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 42745f36978..5dfcd809acc 100644
--- a/ext/sockets/tests/socket_addrinfo_lookup.phpt
+++ b/ext/sockets/tests/socket_addrinfo_lookup.phpt
@@ -11,9 +11,9 @@
         'invalid' => null,
     ));
     var_dump($addrinfo[0]);
-} catch (\ValueError $e) {
-    echo $e->getMessage(), \PHP_EOL;
+} catch (\Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 ?>
 --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 b70900f6862..3bf3bd8789a 100644
--- a/ext/sockets/tests/socket_bind_invalid_port.phpt
+++ b/ext/sockets/tests/socket_bind_invalid_port.phpt
@@ -8,16 +8,16 @@

     try {
     	socket_bind($s_c, '0.0.0.0', -1);
-    } catch (\ValueError $e) {
-	    echo $e->getMessage() . PHP_EOL;
+    } catch (\Throwable $e) {
+	    echo $e::class, ': ', $e->getMessage(), "\n";
     }

     try {
     	socket_bind($s_c, '0.0.0.0', 65536);
-    } catch (\ValueError $e) {
-	    echo $e->getMessage() . PHP_EOL;
+    } catch (\Throwable $e) {
+	    echo $e::class, ': ', $e->getMessage(), "\n";
     }
 ?>
 --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 38a91406651..24e9e731d1d 100644
--- a/ext/sockets/tests/socket_cmsg_udp_segment.phpt
+++ b/ext/sockets/tests/socket_cmsg_udp_segment.phpt
@@ -12,15 +12,15 @@

 try {
 	socket_setopt($src, SOL_UDP, UDP_SEGMENT, -1);
-} catch (\ValueError $e) {
-	echo $e->getMessage(), PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
 	socket_setopt($src, SOL_UDP, UDP_SEGMENT, 65536);
-} catch (\ValueError $e) {
-	echo $e->getMessage(), PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 ?>
 --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 683b8e9d919..6e79bb89df0 100644
--- a/ext/sockets/tests/socket_connect_params.phpt
+++ b/ext/sockets/tests/socket_connect_params.phpt
@@ -14,20 +14,20 @@
 // wrong parameter count
 try {
     socket_connect($s_c);
-} catch (\ArgumentCountError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+} catch (\Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
     socket_connect($s_c, '0.0.0.0');
-} catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+} catch (\Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 $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 35182139ee6..8aa577b1de1 100644
--- a/ext/sockets/tests/socket_create_listen_invalid_port.phpt
+++ b/ext/sockets/tests/socket_create_listen_invalid_port.phpt
@@ -8,17 +8,17 @@

 try {
 	socket_create_listen(-1);
-} catch (\ValueError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
 	socket_create_listen(65536);
-} catch (\ValueError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 ?>
 --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 1d0a6540841..957828ddfc0 100644
--- a/ext/sockets/tests/socket_create_pair-wrongparams.phpt
+++ b/ext/sockets/tests/socket_create_pair-wrongparams.phpt
@@ -15,22 +15,22 @@

 try {
     var_dump(socket_create_pair(31337, 0, 0, $sockets));
-} catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+} catch (\Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }

 try {
     var_dump(socket_create_pair(AF_INET, 31337, 0, $sockets));
-} catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+} catch (\Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }

 ?>
 --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 5e31b155034..9e4ff0e76fa 100644
--- a/ext/sockets/tests/socket_create_pair_sockexec.phpt
+++ b/ext/sockets/tests/socket_create_pair_sockexec.phpt
@@ -12,23 +12,23 @@
 $sockets = array();
 try {
 	socket_create_pair(AF_UNIX, 11 | SOCK_CLOEXEC, 0, $sockets);
-} catch (\ValueError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
 	socket_create_pair(AF_UNIX, 11 | SOCK_NONBLOCK, 0, $sockets);
-} catch (\ValueError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
 	socket_create_pair(AF_UNIX, 11 | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, $sockets);
-} catch (\ValueError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 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 0a83ef485ba..638b17ed41c 100644
--- a/ext/sockets/tests/socket_export_stream-2.phpt
+++ b/ext/sockets/tests/socket_export_stream-2.phpt
@@ -7,13 +7,13 @@

 try {
     socket_export_stream(fopen(__FILE__, "rb"));
-} catch (TypeError $e) {
-    echo $e->getMessage(), "\n";
+} catch (Throwable $e) {
+    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";
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 $s = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
 var_dump($s);
@@ -21,16 +21,16 @@

 try {
     var_dump(socket_export_stream($s));
-} catch (Error $e) {
-    echo $e->getMessage(), "\n";
+} catch (Throwable $e) {
+    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 16867113868..4512ea837b5 100644
--- a/ext/sockets/tests/socket_export_stream-4.phpt
+++ b/ext/sockets/tests/socket_export_stream-4.phpt
@@ -17,8 +17,8 @@ function test($stream, $sock) {
         echo "stream_set_blocking ";
         try {
             print_r(stream_set_blocking($stream, false));
-        } catch (Error $e) {
-            echo get_class($e), ": ", $e->getMessage(), "\n";
+        } catch (Throwable $e) {
+            echo $e::class, ': ', $e->getMessage(), "\n";
         }
         echo "\n";
     }
@@ -26,8 +26,8 @@ function test($stream, $sock) {
         echo "socket_set_block ";
         try {
             print_r(socket_set_block($sock));
-        } catch (Error $e) {
-            echo get_class($e), ": ", $e->getMessage(), "\n";
+        } catch (Throwable $e) {
+            echo $e::class, ': ', $e->getMessage(), "\n";
         }
         echo "\n";
         echo "socket_get_option ";
@@ -35,8 +35,8 @@ function test($stream, $sock) {
             // Solaris uses different numeric values for SOCK_* constants
             $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";
+        } catch (Throwable $e) {
+            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 a2455821e70..9875e1894d3 100644
--- a/ext/sockets/tests/socket_getaddrinfo_error.phpt
+++ b/ext/sockets/tests/socket_getaddrinfo_error.phpt
@@ -11,8 +11,8 @@
 		'ai_flags' => 0,
 		'ai_protocol' => 0,
 	));
-} catch (\TypeError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
 	socket_addrinfo_lookup('127.0.0.1', 2000, array(
@@ -21,8 +21,8 @@
 		'ai_flags' => 0,
 		'ai_protocol' => 0,
 	));
-} catch (\TypeError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
 	socket_addrinfo_lookup('127.0.0.1', 2000, array(
@@ -31,8 +31,8 @@
 		'ai_flags' => new stdClass(),
 		'ai_protocol' => 0,
 	));
-} catch (\TypeError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
 	socket_addrinfo_lookup('127.0.0.1', 2000, array(
@@ -41,8 +41,8 @@
 		'ai_flags' => 0,
 		'ai_protocol' => new stdClass(),
 	));
-} catch (\TypeError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
 	socket_addrinfo_lookup('127.0.0.1', 2000, array(
@@ -51,8 +51,8 @@
 		'ai_flags' => 0,
 		'ai_protocol' => 0,
 	));
-} catch (\ValueError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
 	socket_addrinfo_lookup('127.0.0.1', 2000, array(
@@ -61,8 +61,8 @@
 		'ai_flags' => 0,
 		'ai_protocol' => 0,
 	));
-} catch (\ValueError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
 	socket_addrinfo_lookup('127.0.0.1', 2000, array(
@@ -71,8 +71,8 @@
 		'ai_flags' => -256,
 		'ai_protocol' => 0,
 	));
-} catch (\ValueError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
 	socket_addrinfo_lookup('127.0.0.1', 2000, array(
@@ -81,8 +81,8 @@
 		'ai_flags' => 0,
 		'ai_protocol' => PHP_INT_MIN,
 	));
-} catch (\ValueError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
 	socket_addrinfo_lookup('127.0.0.1', 2000, [
@@ -91,8 +91,8 @@
 		0,
 		0,
 	]);
-} catch (\ValueError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
 	socket_addrinfo_lookup('127.0.0.1', 2000, array(
@@ -101,18 +101,18 @@
 		0,
 		0,
 	));
-} catch (\ValueError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 ?>
 --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 7d3b492a85e..271aab93592 100644
--- a/ext/sockets/tests/socket_import_stream-2.phpt
+++ b/ext/sockets/tests/socket_import_stream-2.phpt
@@ -8,16 +8,16 @@
 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";
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 $s = stream_socket_server("udp://127.0.0.1:0", $errno, $errstr, STREAM_SERVER_BIND);
 var_dump($s);
 var_dump(fclose($s));
 try {
     socket_import_stream($s);
-} catch (TypeError $e) {
-    echo $e->getMessage(), "\n";
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }

 echo "Done.";
@@ -25,8 +25,8 @@
 --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 87ca608b862..585c18285b6 100644
--- a/ext/sockets/tests/socket_import_stream-4.phpt
+++ b/ext/sockets/tests/socket_import_stream-4.phpt
@@ -16,8 +16,8 @@ function test($stream, $sock) {
         echo "stream_set_blocking ";
         try {
             print_r(stream_set_blocking($stream, false));
-        } catch (Error $e) {
-            echo get_class($e), ": ", $e->getMessage(), "\n";
+        } catch (Throwable $e) {
+            echo $e::class, ': ', $e->getMessage(), "\n";
         }
         echo "\n";
     }
@@ -25,8 +25,8 @@ function test($stream, $sock) {
         echo "socket_set_block ";
         try {
             print_r(socket_set_block($sock));
-        } catch (Error $e) {
-            echo get_class($e), ": ", $e->getMessage(), "\n";
+        } catch (Throwable $e) {
+            echo $e::class, ': ', $e->getMessage(), "\n";
         }
         echo "\n";
         echo "socket_get_option ";
@@ -34,8 +34,8 @@ function test($stream, $sock) {
             // Solaris uses different numeric values for SOCK_* constants
             $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";
+        } catch (Throwable $e) {
+            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 a9b8d5c731f..11792b1b812 100644
--- a/ext/sockets/tests/socket_reuseport_cbpf.phpt
+++ b/ext/sockets/tests/socket_reuseport_cbpf.phpt
@@ -20,7 +20,7 @@
 var_dump(socket_set_option( $socket, SOL_SOCKET, SO_REUSEPORT, true));
 try {
 	socket_set_option( $socket, SOL_SOCKET, SO_ATTACH_REUSEPORT_CBPF, []);
-} catch (\TypeError $e) {
+} catch (\Throwable $e) {
 	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 var_dump(socket_set_option( $socket, SOL_SOCKET, SO_ATTACH_REUSEPORT_CBPF, SKF_AD_CPU));
diff --git a/ext/sockets/tests/socket_select-wrongparams-2.phpt b/ext/sockets/tests/socket_select-wrongparams-2.phpt
index f2d3799e757..0e86e924f01 100644
--- a/ext/sockets/tests/socket_select-wrongparams-2.phpt
+++ b/ext/sockets/tests/socket_select-wrongparams-2.phpt
@@ -11,12 +11,12 @@

 try {
     socket_select($sockets, $write, $except, $time);
-} catch (ValueError $exception) {
-    echo $exception->getMessage() . "\n";
+} catch (Throwable $exception) {
+    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 143351dd427..d9c103b1d35 100644
--- a/ext/sockets/tests/socket_select_error.phpt
+++ b/ext/sockets/tests/socket_select_error.phpt
@@ -7,9 +7,9 @@
 $r = $w = $e = ['no resource'];
 try {
     socket_select($r, $w, $e, 1);
-} catch (TypeError $ex) {
-    echo $ex->getMessage(), PHP_EOL;
+} catch (Throwable $ex) {
+    echo $ex::class, ': ', $ex->getMessage(), "\n";
 }
 ?>
 --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 d6294c49010..c3171ebc566 100644
--- a/ext/sockets/tests/socket_send_params.phpt
+++ b/ext/sockets/tests/socket_send_params.phpt
@@ -7,10 +7,10 @@
     $s_c = socket_create_listen(0);
     try {
         $s_w = socket_send($s_c, "foo", -1, MSG_OOB);
-    } catch (\ValueError $e) {
-        echo $e->getMessage() . \PHP_EOL;
+    } catch (\Throwable $e) {
+        echo $e::class, ': ', $e->getMessage(), "\n";
     }
     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 9ff81ff5e15..d0778ca9817 100644
--- a/ext/sockets/tests/socket_sendto_invalid_port.phpt
+++ b/ext/sockets/tests/socket_sendto_invalid_port.phpt
@@ -7,16 +7,16 @@
     $s_c = socket_create_listen(0);
     try {
         $s_w = socket_sendto($s_c, "foo", 0, MSG_OOB, '127.0.0.1', 65536);
-    } catch (\ValueError $e) {
-        echo $e->getMessage() . \PHP_EOL;
+    } catch (\Throwable $e) {
+        echo $e::class, ': ', $e->getMessage(), "\n";
     }
     try {
         $s_w = socket_sendto($s_c, "foo", 0, MSG_OOB, '127.0.0.1', -1);
-    } catch (\ValueError $e) {
-        echo $e->getMessage() . \PHP_EOL;
+    } catch (\Throwable $e) {
+        echo $e::class, ': ', $e->getMessage(), "\n";
     }
     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 ed805ee9be7..78db7cb95dc 100644
--- a/ext/sockets/tests/socket_sendto_params.phpt
+++ b/ext/sockets/tests/socket_sendto_params.phpt
@@ -7,10 +7,10 @@
     $s_c = socket_create_listen(0);
     try {
         $s_w = socket_sendto($s_c, "foo", -1, MSG_OOB, '127.0.0.1');
-    } catch (\ValueError $e) {
-        echo $e->getMessage() . \PHP_EOL;
+    } catch (\Throwable $e) {
+        echo $e::class, ': ', $e->getMessage(), "\n";
     }
     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 f2b62527e33..7203308d742 100644
--- a/ext/sockets/tests/socket_sendto_unix_addr_too_long.phpt
+++ b/ext/sockets/tests/socket_sendto_unix_addr_too_long.phpt
@@ -19,11 +19,11 @@

 try {
     socket_sendto($socket, "data", 4, 0, $long_addr);
-} catch (\ValueError $e) {
-    echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }

 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 04f98041683..648847b539b 100644
--- a/ext/sockets/tests/socket_set_block-retval.phpt
+++ b/ext/sockets/tests/socket_set_block-retval.phpt
@@ -13,11 +13,11 @@
 socket_close($socket2);
 try {
     var_dump(socket_set_block($socket2));
-} catch (Error $e) {
-    echo $e->getMessage(), "\n";
+} catch (Throwable $e) {
+    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 b92a75e17c2..bc32f79782b 100644
--- a/ext/sockets/tests/socket_set_nonblock-retval.phpt
+++ b/ext/sockets/tests/socket_set_nonblock-retval.phpt
@@ -13,11 +13,11 @@
 socket_close($socket2);
 try {
     var_dump(socket_set_nonblock($socket2));
-} catch (Error $e) {
-    echo $e->getMessage(), "\n";
+} catch (Throwable $e) {
+    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 0d7630fb279..0fdb4ed8f5b 100644
--- a/ext/sockets/tests/socket_set_option_mcast_error.phpt
+++ b/ext/sockets/tests/socket_set_option_mcast_error.phpt
@@ -21,16 +21,16 @@

 try {
 	socket_set_option($s, $level, MCAST_LEAVE_GROUP, $iwanttoleavenow);
-} catch (\TypeError $e) {
-	echo $e->getMessage(), PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }

 try {
 	socket_set_option($s, $level, MCAST_LEAVE_SOURCE_GROUP, $iwanttoleavenow);
-} catch (\TypeError $e) {
-	echo $e->getMessage();
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 ?>
 --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 ef75ee02537..411f6da2af3 100644
--- a/ext/sockets/tests/socket_set_option_rcvtimeo.phpt
+++ b/ext/sockets/tests/socket_set_option_rcvtimeo.phpt
@@ -16,8 +16,8 @@
 //wrong params
 try {
     $retval_1 = socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, []);
-} catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+} catch (\Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }

 //set/get comparison
@@ -30,6 +30,6 @@
 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 0450c752509..62b79629c3c 100644
--- a/ext/sockets/tests/socket_set_option_seolinger.phpt
+++ b/ext/sockets/tests/socket_set_option_seolinger.phpt
@@ -16,8 +16,8 @@
 // wrong params
 try {
     $retval_1 = socket_set_option( $socket, SOL_SOCKET, SO_LINGER, []);
-} catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+} catch (\Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }

 // set/get comparison
@@ -29,8 +29,8 @@
 $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;
+} catch (\Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }

 var_dump($retval_2);
@@ -41,8 +41,8 @@
 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 e7487f75b05..ec162b4dbd7 100644
--- a/ext/sockets/tests/socket_set_option_sndtimeo.phpt
+++ b/ext/sockets/tests/socket_set_option_sndtimeo.phpt
@@ -16,8 +16,8 @@
 //wrong params
 try {
     $retval_1 = socket_set_option( $socket, SOL_SOCKET, SO_SNDTIMEO, []);
-} catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+} catch (\Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }

 //set/get comparison
@@ -30,6 +30,6 @@
 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 befdfb09585..5e95dd65a81 100644
--- a/ext/sockets/tests/socket_set_option_timeo_error.phpt
+++ b/ext/sockets/tests/socket_set_option_timeo_error.phpt
@@ -17,57 +17,57 @@

 try {
 	socket_set_option( $socket, SOL_SOCKET, SO_RCVTIMEO, new stdClass);
-} catch (\ValueError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }

 try {
 	socket_set_option( $socket, SOL_SOCKET, SO_RCVTIMEO, $options_1);
-} catch (\TypeError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }

 try {
 	socket_set_option( $socket, SOL_SOCKET, SO_SNDTIMEO, $options_2);
-} catch (\TypeError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
 	socket_set_option( $socket, SOL_SOCKET, SO_RCVTIMEO, "not good");
-} catch (\TypeError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
 	socket_set_option( $socket, SOL_SOCKET, SO_LINGER, "not good neither");
-} catch (\TypeError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
 	socket_set_option( $socket, SOL_SOCKET, SO_LINGER, $options_3);
-} catch (\TypeError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
 	socket_set_option( $socket, SOL_SOCKET, SO_LINGER, $options_4);
-} catch (\TypeError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
 	socket_set_option( $socket, SOL_SOCKET, SO_LINGER, $options_5);
-} catch (\ValueError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
 	socket_set_option( $socket, SOL_SOCKET, SO_LINGER, $options_6);
-} catch (\ValueError $e) {
-	echo $e->getMessage() . PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 ?>
 --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 894a24d2a49..62491154523 100644
--- a/ext/sockets/tests/socket_setoption_tcpusertimeout_64bit.phpt
+++ b/ext/sockets/tests/socket_setoption_tcpusertimeout_64bit.phpt
@@ -17,14 +17,14 @@

 try {
 	socket_setopt($socket, SOL_TCP, TCP_USER_TIMEOUT, -1);
-} catch (\ValueError $e) {
-	echo $e->getMessage(), PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }

 try {
 	socket_setopt($socket, SOL_TCP, TCP_USER_TIMEOUT, PHP_INT_MAX);
-} catch (\ValueError $e) {
-	echo $e->getMessage(), PHP_EOL;
+} catch (\Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }

 $timeout = 200;
@@ -35,7 +35,7 @@
 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)