Skip to content

Commit de2c87f

Browse files
authored
Merge pull request #187 from clue-labs/namespace-docs
Update documentation to use full class names with namespaces
2 parents 78a2591 + 1e5370a commit de2c87f

11 files changed

+120
-120
lines changed

README.md

Lines changed: 82 additions & 82 deletions
Large diffs are not rendered by default.

examples/01-echo-server.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
)
3131
));
3232

33-
$server->on('connection', function (ConnectionInterface $conn) {
34-
echo '[' . $conn->getRemoteAddress() . ' connected]' . PHP_EOL;
35-
$conn->pipe($conn);
33+
$server->on('connection', function (ConnectionInterface $connection) {
34+
echo '[' . $connection->getRemoteAddress() . ' connected]' . PHP_EOL;
35+
$connection->pipe($connection);
3636
});
3737

3838
$server->on('error', 'printf');

examples/03-http-server.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@
4343
)
4444
));
4545

46-
$server->on('connection', function (ConnectionInterface $conn) {
47-
$conn->once('data', function () use ($conn) {
46+
$server->on('connection', function (ConnectionInterface $connection) {
47+
$connection->once('data', function () use ($connection) {
4848
$body = "<html><h1>Hello world!</h1></html>\r\n";
49-
$conn->end("HTTP/1.1 200 OK\r\nContent-Length: " . strlen($body) . "\r\nConnection: close\r\n\r\n" . $body);
49+
$connection->end("HTTP/1.1 200 OK\r\nContent-Length: " . strlen($body) . "\r\nConnection: close\r\n\r\n" . $body);
5050
});
5151
});
5252

examples/91-benchmark-server.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@
3636
)
3737
));
3838

39-
$server->on('connection', function (ConnectionInterface $conn) use ($loop) {
39+
$server->on('connection', function (ConnectionInterface $connection) use ($loop) {
4040
echo '[connected]' . PHP_EOL;
4141

4242
// count the number of bytes received from this connection
4343
$bytes = 0;
44-
$conn->on('data', function ($chunk) use (&$bytes) {
44+
$connection->on('data', function ($chunk) use (&$bytes) {
4545
$bytes += strlen($chunk);
4646
});
4747

4848
// report average throughput once client disconnects
4949
$t = microtime(true);
50-
$conn->on('close', function () use ($conn, $t, &$bytes) {
50+
$connection->on('close', function () use ($connection, $t, &$bytes) {
5151
$t = microtime(true) - $t;
5252
echo '[disconnected after receiving ' . $bytes . ' bytes in ' . round($t, 3) . 's => ' . round($bytes / $t / 1024 / 1024, 1) . ' MiB/s]' . PHP_EOL;
5353
});

src/ConnectorInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ interface ConnectorInterface
3030
*
3131
* ```php
3232
* $connector->connect('google.com:443')->then(
33-
* function (ConnectionInterface $connection) {
33+
* function (React\Socket\ConnectionInterface $connection) {
3434
* // connection successfully established
3535
* },
3636
* function (Exception $error) {

src/FixedUriConnector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
* instead of connecting to a default address assumed by an higher-level API:
1111
*
1212
* ```php
13-
* $connector = new FixedUriConnector(
13+
* $connector = new React\Socket\FixedUriConnector(
1414
* 'unix:///var/run/docker.sock',
15-
* new UnixConnector($loop)
15+
* new React\Socket\UnixConnector($loop)
1616
* );
1717
*
1818
* // destination will be ignored, actually connects to Unix domain socket

src/LimitingServer.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
* open connections.
2222
*
2323
* ```php
24-
* $server = new LimitingServer($server, 100);
25-
* $server->on('connection', function (ConnectionInterface $connection) {
24+
* $server = new React\Socket\LimitingServer($server, 100);
25+
* $server->on('connection', function (React\Socket\ConnectionInterface $connection) {
2626
* $connection->write('hello there!' . PHP_EOL);
2727
* …
2828
* });
@@ -52,8 +52,8 @@ class LimitingServer extends EventEmitter implements ServerInterface
5252
* this and no `connection` event will be emitted.
5353
*
5454
* ```php
55-
* $server = new LimitingServer($server, 100);
56-
* $server->on('connection', function (ConnectionInterface $connection) {
55+
* $server = new React\Socket\LimitingServer($server, 100);
56+
* $server->on('connection', function (React\Socket\ConnectionInterface $connection) {
5757
* $connection->write('hello there!' . PHP_EOL);
5858
* …
5959
* });
@@ -81,8 +81,8 @@ class LimitingServer extends EventEmitter implements ServerInterface
8181
* an interactive chat).
8282
*
8383
* ```php
84-
* $server = new LimitingServer($server, 100, true);
85-
* $server->on('connection', function (ConnectionInterface $connection) {
84+
* $server = new React\Socket\LimitingServer($server, 100, true);
85+
* $server->on('connection', function (React\Socket\ConnectionInterface $connection) {
8686
* $connection->write('hello there!' . PHP_EOL);
8787
* …
8888
* });

src/SecureServer.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
* TCP/IP connections and then performs a TLS handshake for each connection.
1616
*
1717
* ```php
18-
* $server = new TcpServer(8000, $loop);
19-
* $server = new SecureServer($server, $loop, array(
18+
* $server = new React\Socket\TcpServer(8000, $loop);
19+
* $server = new React\Socket\SecureServer($server, $loop, array(
2020
* // tls context options here…
2121
* ));
2222
* ```
@@ -25,7 +25,7 @@
2525
* with a connection instance implementing [`ConnectionInterface`](#connectioninterface):
2626
*
2727
* ```php
28-
* $server->on('connection', function (ConnectionInterface $connection) {
28+
* $server->on('connection', function (React\Socket\ConnectionInterface $connection) {
2929
* echo 'Secure connection from' . $connection->getRemoteAddress() . PHP_EOL;
3030
*
3131
* $connection->write('hello there!' . PHP_EOL);
@@ -67,8 +67,8 @@ final class SecureServer extends EventEmitter implements ServerInterface
6767
* PEM encoded certificate file:
6868
*
6969
* ```php
70-
* $server = new TcpServer(8000, $loop);
71-
* $server = new SecureServer($server, $loop, array(
70+
* $server = new React\Socket\TcpServer(8000, $loop);
71+
* $server = new React\Socket\SecureServer($server, $loop, array(
7272
* 'local_cert' => 'server.pem'
7373
* ));
7474
* ```
@@ -82,8 +82,8 @@ final class SecureServer extends EventEmitter implements ServerInterface
8282
* like this:
8383
*
8484
* ```php
85-
* $server = new TcpServer(8000, $loop);
86-
* $server = new SecureServer($server, $loop, array(
85+
* $server = new React\Socket\TcpServer(8000, $loop);
86+
* $server = new React\Socket\SecureServer($server, $loop, array(
8787
* 'local_cert' => 'server.pem',
8888
* 'passphrase' => 'secret'
8989
* ));

src/ServerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* established, i.e. a new client connects to this server socket:
2424
*
2525
* ```php
26-
* $server->on('connection', function (ConnectionInterface $connection) {
26+
* $server->on('connection', function (React\Socket\ConnectionInterface $connection) {
2727
* echo 'new connection' . PHP_EOL;
2828
* });
2929
* ```

src/TcpServer.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
* is responsible for accepting plaintext TCP/IP connections.
1313
*
1414
* ```php
15-
* $server = new TcpServer(8080, $loop);
15+
* $server = new React\Socket\TcpServer(8080, $loop);
1616
* ```
1717
*
1818
* Whenever a client connects, it will emit a `connection` event with a connection
1919
* instance implementing `ConnectionInterface`:
2020
*
2121
* ```php
22-
* $server->on('connection', function (ConnectionInterface $connection) {
22+
* $server->on('connection', function (React\Socket\ConnectionInterface $connection) {
2323
* echo 'Plaintext connection from ' . $connection->getRemoteAddress() . PHP_EOL;
2424
* $connection->write('hello there!' . PHP_EOL);
2525
* …
@@ -45,7 +45,7 @@ final class TcpServer extends EventEmitter implements ServerInterface
4545
* for more details.
4646
*
4747
* ```php
48-
* $server = new TcpServer(8080, $loop);
48+
* $server = new React\Socket\TcpServer(8080, $loop);
4949
* ```
5050
*
5151
* As above, the `$uri` parameter can consist of only a port, in which case the
@@ -55,7 +55,7 @@ final class TcpServer extends EventEmitter implements ServerInterface
5555
* In order to use a random port assignment, you can use the port `0`:
5656
*
5757
* ```php
58-
* $server = new TcpServer(0, $loop);
58+
* $server = new React\Socket\TcpServer(0, $loop);
5959
* $address = $server->getAddress();
6060
* ```
6161
*
@@ -64,33 +64,33 @@ final class TcpServer extends EventEmitter implements ServerInterface
6464
* preceded by the `tcp://` scheme:
6565
*
6666
* ```php
67-
* $server = new TcpServer('192.168.0.1:8080', $loop);
67+
* $server = new React\Socket\TcpServer('192.168.0.1:8080', $loop);
6868
* ```
6969
*
7070
* If you want to listen on an IPv6 address, you MUST enclose the host in square
7171
* brackets:
7272
*
7373
* ```php
74-
* $server = new TcpServer('[::1]:8080', $loop);
74+
* $server = new React\Socket\TcpServer('[::1]:8080', $loop);
7575
* ```
7676
*
7777
* If the given URI is invalid, does not contain a port, any other scheme or if it
7878
* contains a hostname, it will throw an `InvalidArgumentException`:
7979
*
8080
* ```php
8181
* // throws InvalidArgumentException due to missing port
82-
* $server = new TcpServer('127.0.0.1', $loop);
82+
* $server = new React\Socket\TcpServer('127.0.0.1', $loop);
8383
* ```
8484
*
8585
* If the given URI appears to be valid, but listening on it fails (such as if port
8686
* is already in use or port below 1024 may require root access etc.), it will
8787
* throw a `RuntimeException`:
8888
*
8989
* ```php
90-
* $first = new TcpServer(8080, $loop);
90+
* $first = new React\Socket\TcpServer(8080, $loop);
9191
*
9292
* // throws RuntimeException because port is already in use
93-
* $second = new TcpServer(8080, $loop);
93+
* $second = new React\Socket\TcpServer(8080, $loop);
9494
* ```
9595
*
9696
* Note that these error conditions may vary depending on your system and/or
@@ -102,7 +102,7 @@ final class TcpServer extends EventEmitter implements ServerInterface
102102
* for the underlying stream socket resource like this:
103103
*
104104
* ```php
105-
* $server = new TcpServer('[::1]:8080', $loop, array(
105+
* $server = new React\Socket\TcpServer('[::1]:8080', $loop, array(
106106
* 'backlog' => 200,
107107
* 'so_reuseport' => true,
108108
* 'ipv6_v6only' => true

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy