@@ -423,13 +423,13 @@ Optionally, you can specify [TCP socket context options](https://www.php.net/man
423423for the underlying stream socket resource like this:
424424
425425``` php
426- $socket = new React\Socket\SocketServer('[::1]:8080', array(
427- 'tcp' => array(
426+ $socket = new React\Socket\SocketServer('[::1]:8080', [
427+ 'tcp' => [
428428 'backlog' => 200,
429429 'so_reuseport' => true,
430430 'ipv6_v6only' => true
431- )
432- ) );
431+ ]
432+ ] );
433433```
434434
435435> Note that available [ socket context options] ( https://www.php.net/manual/en/context.socket.php ) ,
@@ -447,11 +447,11 @@ which in its most basic form may look something like this if you're using a
447447PEM encoded certificate file:
448448
449449``` php
450- $socket = new React\Socket\SocketServer('tls://127.0.0.1:8080', array(
451- 'tls' => array(
450+ $socket = new React\Socket\SocketServer('tls://127.0.0.1:8080', [
451+ 'tls' => [
452452 'local_cert' => 'server.pem'
453- )
454- ) );
453+ ]
454+ ] );
455455```
456456
457457> Note that the certificate file will not be loaded on instantiation but when an
@@ -463,25 +463,25 @@ If your private key is encrypted with a passphrase, you have to specify it
463463like this:
464464
465465``` php
466- $socket = new React\Socket\SocketServer('tls://127.0.0.1:8000', array(
467- 'tls' => array(
466+ $socket = new React\Socket\SocketServer('tls://127.0.0.1:8000', [
467+ 'tls' => [
468468 'local_cert' => 'server.pem',
469469 'passphrase' => 'secret'
470- )
471- ) );
470+ ]
471+ ] );
472472```
473473
474474By default, this server supports TLSv1.0+ and excludes support for legacy
475475SSLv2/SSLv3. You can also explicitly choose the TLS version you
476476want to negotiate with the remote side:
477477
478478``` php
479- $socket = new React\Socket\SocketServer('tls://127.0.0.1:8000', array(
480- 'tls' => array(
479+ $socket = new React\Socket\SocketServer('tls://127.0.0.1:8000', [
480+ 'tls' => [
481481 'local_cert' => 'server.pem',
482482 'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_SERVER
483- )
484- ) );
483+ ]
484+ ] );
485485```
486486
487487> Note that available [ TLS context options] ( https://www.php.net/manual/en/context.ssl.php ) ,
@@ -588,11 +588,11 @@ Optionally, you can specify [socket context options](https://www.php.net/manual/
588588for the underlying stream socket resource like this:
589589
590590``` php
591- $server = new React\Socket\TcpServer('[::1]:8080', null, array(
591+ $server = new React\Socket\TcpServer('[::1]:8080', null, [
592592 'backlog' => 200,
593593 'so_reuseport' => true,
594594 'ipv6_v6only' => true
595- ) );
595+ ] );
596596```
597597
598598> Note that available [ socket context options] ( https://www.php.net/manual/en/context.socket.php ) ,
@@ -628,9 +628,9 @@ PEM encoded certificate file:
628628
629629``` php
630630$server = new React\Socket\TcpServer(8000);
631- $server = new React\Socket\SecureServer($server, null, array(
631+ $server = new React\Socket\SecureServer($server, null, [
632632 'local_cert' => 'server.pem'
633- ) );
633+ ] );
634634```
635635
636636> Note that the certificate file will not be loaded on instantiation but when an
@@ -643,10 +643,10 @@ like this:
643643
644644``` php
645645$server = new React\Socket\TcpServer(8000);
646- $server = new React\Socket\SecureServer($server, null, array(
646+ $server = new React\Socket\SecureServer($server, null, [
647647 'local_cert' => 'server.pem',
648648 'passphrase' => 'secret'
649- ) );
649+ ] );
650650```
651651
652652By default, this server supports TLSv1.0+ and excludes support for legacy
@@ -655,10 +655,10 @@ want to negotiate with the remote side:
655655
656656``` php
657657$server = new React\Socket\TcpServer(8000);
658- $server = new React\Socket\SecureServer($server, null, array(
658+ $server = new React\Socket\SecureServer($server, null, [
659659 'local_cert' => 'server.pem',
660660 'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_SERVER
661- ) );
661+ ] );
662662```
663663
664664> Note that available [ TLS context options] ( https://www.php.net/manual/en/context.ssl.php ) ,
@@ -971,9 +971,9 @@ If you want to revert to the old behavior of only doing an IPv4 lookup and
971971only attempt a single IPv4 connection, you can set up the ` Connector ` like this:
972972
973973``` php
974- $connector = new React\Socket\Connector(array(
974+ $connector = new React\Socket\Connector([
975975 'happy_eyeballs' => false
976- ) );
976+ ] );
977977```
978978
979979Similarly, you can also affect the default DNS behavior as follows.
@@ -985,9 +985,9 @@ If you explicitly want to use a custom DNS server (such as a local DNS relay or
985985a company wide DNS server), you can set up the ` Connector ` like this:
986986
987987``` php
988- $connector = new React\Socket\Connector(array(
988+ $connector = new React\Socket\Connector([
989989 'dns' => '127.0.1.1'
990- ) );
990+ ] );
991991
992992$connector->connect('localhost:80')->then(function (React\Socket\ConnectionInterface $connection) {
993993 $connection->write('...');
@@ -999,9 +999,9 @@ If you do not want to use a DNS resolver at all and want to connect to IP
999999addresses only, you can also set up your ` Connector ` like this:
10001000
10011001``` php
1002- $connector = new React\Socket\Connector(array(
1002+ $connector = new React\Socket\Connector([
10031003 'dns' => false
1004- ) );
1004+ ] );
10051005
10061006$connector->connect('127.0.0.1:80')->then(function (React\Socket\ConnectionInterface $connection) {
10071007 $connection->write('...');
@@ -1016,9 +1016,9 @@ can also set up your `Connector` like this:
10161016$dnsResolverFactory = new React\Dns\Resolver\Factory();
10171017$resolver = $dnsResolverFactory->createCached('127.0.1.1');
10181018
1019- $connector = new React\Socket\Connector(array(
1019+ $connector = new React\Socket\Connector([
10201020 'dns' => $resolver
1021- ) );
1021+ ] );
10221022
10231023$connector->connect('localhost:80')->then(function (React\Socket\ConnectionInterface $connection) {
10241024 $connection->write('...');
@@ -1031,18 +1031,18 @@ respects your `default_socket_timeout` ini setting (which defaults to 60s).
10311031If you want a custom timeout value, you can simply pass this like this:
10321032
10331033``` php
1034- $connector = new React\Socket\Connector(array(
1034+ $connector = new React\Socket\Connector([
10351035 'timeout' => 10.0
1036- ) );
1036+ ] );
10371037```
10381038
10391039Similarly, if you do not want to apply a timeout at all and let the operating
10401040system handle this, you can pass a boolean flag like this:
10411041
10421042``` php
1043- $connector = new React\Socket\Connector(array(
1043+ $connector = new React\Socket\Connector([
10441044 'timeout' => false
1045- ) );
1045+ ] );
10461046```
10471047
10481048By default, the ` Connector ` supports the ` tcp:// ` , ` tls:// ` and ` unix:// `
@@ -1051,7 +1051,7 @@ pass boolean flags like this:
10511051
10521052``` php
10531053// only allow secure TLS connections
1054- $connector = new React\Socket\Connector(array(
1054+ $connector = new React\Socket\Connector([
10551055 'tcp' => false,
10561056 'tls' => true,
10571057 'unix' => false,
@@ -1070,15 +1070,15 @@ pass arrays of context options like this:
10701070
10711071``` php
10721072// allow insecure TLS connections
1073- $connector = new React\Socket\Connector(array(
1074- 'tcp' => array(
1073+ $connector = new React\Socket\Connector([
1074+ 'tcp' => [
10751075 'bindto' => '192.168.0.1:0'
1076- ) ,
1077- 'tls' => array(
1076+ ] ,
1077+ 'tls' => [
10781078 'verify_peer' => false,
10791079 'verify_peer_name' => false
1080- ) ,
1081- ) );
1080+ ] ,
1081+ ] );
10821082
10831083$connector->connect('tls://localhost:443')->then(function (React\Socket\ConnectionInterface $connection) {
10841084 $connection->write('...');
@@ -1091,11 +1091,11 @@ SSLv2/SSLv3. You can also explicitly choose the TLS version you
10911091want to negotiate with the remote side:
10921092
10931093``` php
1094- $connector = new React\Socket\Connector(array(
1095- 'tls' => array(
1094+ $connector = new React\Socket\Connector([
1095+ 'tls' => [
10961096 'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT
1097- )
1098- ) );
1097+ ]
1098+ ] );
10991099```
11001100
11011101> For more details about context options, please refer to the PHP documentation
@@ -1117,14 +1117,14 @@ $tls = new React\Socket\SecureConnector($tcp);
11171117
11181118$unix = new React\Socket\UnixConnector();
11191119
1120- $connector = new React\Socket\Connector(array(
1120+ $connector = new React\Socket\Connector([
11211121 'tcp' => $tcp,
11221122 'tls' => $tls,
11231123 'unix' => $unix,
11241124
11251125 'dns' => false,
11261126 'timeout' => false,
1127- ) );
1127+ ] );
11281128
11291129$connector->connect('google.com:80')->then(function (React\Socket\ConnectionInterface $connection) {
11301130 $connection->write('...');
@@ -1192,9 +1192,9 @@ You can optionally pass additional
11921192to the constructor like this:
11931193
11941194``` php
1195- $tcpConnector = new React\Socket\TcpConnector(null, array(
1195+ $tcpConnector = new React\Socket\TcpConnector(null, [
11961196 'bindto' => '192.168.0.1:0'
1197- ) );
1197+ ] );
11981198```
11991199
12001200Note that this class only allows you to connect to IP-port-combinations.
@@ -1363,20 +1363,20 @@ You can optionally pass additional
13631363to the constructor like this:
13641364
13651365``` php
1366- $secureConnector = new React\Socket\SecureConnector($dnsConnector, null, array(
1366+ $secureConnector = new React\Socket\SecureConnector($dnsConnector, null, [
13671367 'verify_peer' => false,
13681368 'verify_peer_name' => false
1369- ) );
1369+ ] );
13701370```
13711371
13721372By default, this connector supports TLSv1.0+ and excludes support for legacy
13731373SSLv2/SSLv3. You can also explicitly choose the TLS version you
13741374want to negotiate with the remote side:
13751375
13761376``` php
1377- $secureConnector = new React\Socket\SecureConnector($dnsConnector, null, array(
1377+ $secureConnector = new React\Socket\SecureConnector($dnsConnector, null, [
13781378 'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT
1379- ) );
1379+ ] );
13801380```
13811381
13821382> Advanced usage: Internally, the ` SecureConnector ` relies on setting up the
0 commit comments