Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ext/sockets/tests/gh16267.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion ext/sockets/tests/gh20532.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ var_dump(socket_addrinfo_lookup("example.com", "http", ['ai_socktype' => SOCK_RA
bool(true)
bool(true)
bool(true)

8 changes: 4 additions & 4 deletions ext/sockets/tests/mcast_ipv4_send_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -78,13 +78,13 @@ 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"
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)
4 changes: 2 additions & 2 deletions ext/sockets/tests/mcast_sockettype_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions ext/sockets/tests/socket_addrinfo_lookup.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
8 changes: 4 additions & 4 deletions ext/sockets/tests/socket_bind_invalid_port.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions ext/sockets/tests/socket_cmsg_udp_segment.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions ext/sockets/tests/socket_connect_params.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions ext/sockets/tests/socket_create_listen_invalid_port.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions ext/sockets/tests/socket_create_pair-wrongparams.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 6 additions & 6 deletions ext/sockets/tests/socket_create_pair_sockexec.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
12 changes: 6 additions & 6 deletions ext/sockets/tests/socket_export_stream-2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.
6 changes: 3 additions & 3 deletions ext/sockets/tests/socket_export_stream-4.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand All @@ -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 ";
Expand All @@ -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";
}
Expand Down
40 changes: 20 additions & 20 deletions ext/sockets/tests/socket_getaddrinfo_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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, [
Expand All @@ -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(
Expand All @@ -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"
Loading
Loading