Skip to content

Update documentation to use full class names with namespaces #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 4, 2019
Merged
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
164 changes: 82 additions & 82 deletions README.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions examples/01-echo-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
)
));

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

$server->on('error', 'printf');
Expand Down
6 changes: 3 additions & 3 deletions examples/03-http-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
)
));

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

Expand Down
6 changes: 3 additions & 3 deletions examples/91-benchmark-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@
)
));

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

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

// report average throughput once client disconnects
$t = microtime(true);
$conn->on('close', function () use ($conn, $t, &$bytes) {
$connection->on('close', function () use ($connection, $t, &$bytes) {
$t = microtime(true) - $t;
echo '[disconnected after receiving ' . $bytes . ' bytes in ' . round($t, 3) . 's => ' . round($bytes / $t / 1024 / 1024, 1) . ' MiB/s]' . PHP_EOL;
});
Expand Down
2 changes: 1 addition & 1 deletion src/ConnectorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface ConnectorInterface
*
* ```php
* $connector->connect('google.com:443')->then(
* function (ConnectionInterface $connection) {
* function (React\Socket\ConnectionInterface $connection) {
* // connection successfully established
* },
* function (Exception $error) {
Expand Down
4 changes: 2 additions & 2 deletions src/FixedUriConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
* instead of connecting to a default address assumed by an higher-level API:
*
* ```php
* $connector = new FixedUriConnector(
* $connector = new React\Socket\FixedUriConnector(
* 'unix:///var/run/docker.sock',
* new UnixConnector($loop)
* new React\Socket\UnixConnector($loop)
* );
*
* // destination will be ignored, actually connects to Unix domain socket
Expand Down
12 changes: 6 additions & 6 deletions src/LimitingServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
* open connections.
*
* ```php
* $server = new LimitingServer($server, 100);
* $server->on('connection', function (ConnectionInterface $connection) {
* $server = new React\Socket\LimitingServer($server, 100);
* $server->on('connection', function (React\Socket\ConnectionInterface $connection) {
* $connection->write('hello there!' . PHP_EOL);
* …
* });
Expand Down Expand Up @@ -52,8 +52,8 @@ class LimitingServer extends EventEmitter implements ServerInterface
* this and no `connection` event will be emitted.
*
* ```php
* $server = new LimitingServer($server, 100);
* $server->on('connection', function (ConnectionInterface $connection) {
* $server = new React\Socket\LimitingServer($server, 100);
* $server->on('connection', function (React\Socket\ConnectionInterface $connection) {
* $connection->write('hello there!' . PHP_EOL);
* …
* });
Expand Down Expand Up @@ -81,8 +81,8 @@ class LimitingServer extends EventEmitter implements ServerInterface
* an interactive chat).
*
* ```php
* $server = new LimitingServer($server, 100, true);
* $server->on('connection', function (ConnectionInterface $connection) {
* $server = new React\Socket\LimitingServer($server, 100, true);
* $server->on('connection', function (React\Socket\ConnectionInterface $connection) {
* $connection->write('hello there!' . PHP_EOL);
* …
* });
Expand Down
14 changes: 7 additions & 7 deletions src/SecureServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* TCP/IP connections and then performs a TLS handshake for each connection.
*
* ```php
* $server = new TcpServer(8000, $loop);
* $server = new SecureServer($server, $loop, array(
* $server = new React\Socket\TcpServer(8000, $loop);
* $server = new React\Socket\SecureServer($server, $loop, array(
* // tls context options here…
* ));
* ```
Expand All @@ -25,7 +25,7 @@
* with a connection instance implementing [`ConnectionInterface`](#connectioninterface):
*
* ```php
* $server->on('connection', function (ConnectionInterface $connection) {
* $server->on('connection', function (React\Socket\ConnectionInterface $connection) {
* echo 'Secure connection from' . $connection->getRemoteAddress() . PHP_EOL;
*
* $connection->write('hello there!' . PHP_EOL);
Expand Down Expand Up @@ -67,8 +67,8 @@ final class SecureServer extends EventEmitter implements ServerInterface
* PEM encoded certificate file:
*
* ```php
* $server = new TcpServer(8000, $loop);
* $server = new SecureServer($server, $loop, array(
* $server = new React\Socket\TcpServer(8000, $loop);
* $server = new React\Socket\SecureServer($server, $loop, array(
* 'local_cert' => 'server.pem'
* ));
* ```
Expand All @@ -82,8 +82,8 @@ final class SecureServer extends EventEmitter implements ServerInterface
* like this:
*
* ```php
* $server = new TcpServer(8000, $loop);
* $server = new SecureServer($server, $loop, array(
* $server = new React\Socket\TcpServer(8000, $loop);
* $server = new React\Socket\SecureServer($server, $loop, array(
* 'local_cert' => 'server.pem',
* 'passphrase' => 'secret'
* ));
Expand Down
2 changes: 1 addition & 1 deletion src/ServerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* established, i.e. a new client connects to this server socket:
*
* ```php
* $server->on('connection', function (ConnectionInterface $connection) {
* $server->on('connection', function (React\Socket\ConnectionInterface $connection) {
* echo 'new connection' . PHP_EOL;
* });
* ```
Expand Down
20 changes: 10 additions & 10 deletions src/TcpServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
* is responsible for accepting plaintext TCP/IP connections.
*
* ```php
* $server = new TcpServer(8080, $loop);
* $server = new React\Socket\TcpServer(8080, $loop);
* ```
*
* Whenever a client connects, it will emit a `connection` event with a connection
* instance implementing `ConnectionInterface`:
*
* ```php
* $server->on('connection', function (ConnectionInterface $connection) {
* $server->on('connection', function (React\Socket\ConnectionInterface $connection) {
* echo 'Plaintext connection from ' . $connection->getRemoteAddress() . PHP_EOL;
* $connection->write('hello there!' . PHP_EOL);
* …
Expand All @@ -45,7 +45,7 @@ final class TcpServer extends EventEmitter implements ServerInterface
* for more details.
*
* ```php
* $server = new TcpServer(8080, $loop);
* $server = new React\Socket\TcpServer(8080, $loop);
* ```
*
* As above, the `$uri` parameter can consist of only a port, in which case the
Expand All @@ -55,7 +55,7 @@ final class TcpServer extends EventEmitter implements ServerInterface
* In order to use a random port assignment, you can use the port `0`:
*
* ```php
* $server = new TcpServer(0, $loop);
* $server = new React\Socket\TcpServer(0, $loop);
* $address = $server->getAddress();
* ```
*
Expand All @@ -64,33 +64,33 @@ final class TcpServer extends EventEmitter implements ServerInterface
* preceded by the `tcp://` scheme:
*
* ```php
* $server = new TcpServer('192.168.0.1:8080', $loop);
* $server = new React\Socket\TcpServer('192.168.0.1:8080', $loop);
* ```
*
* If you want to listen on an IPv6 address, you MUST enclose the host in square
* brackets:
*
* ```php
* $server = new TcpServer('[::1]:8080', $loop);
* $server = new React\Socket\TcpServer('[::1]:8080', $loop);
* ```
*
* If the given URI is invalid, does not contain a port, any other scheme or if it
* contains a hostname, it will throw an `InvalidArgumentException`:
*
* ```php
* // throws InvalidArgumentException due to missing port
* $server = new TcpServer('127.0.0.1', $loop);
* $server = new React\Socket\TcpServer('127.0.0.1', $loop);
* ```
*
* If the given URI appears to be valid, but listening on it fails (such as if port
* is already in use or port below 1024 may require root access etc.), it will
* throw a `RuntimeException`:
*
* ```php
* $first = new TcpServer(8080, $loop);
* $first = new React\Socket\TcpServer(8080, $loop);
*
* // throws RuntimeException because port is already in use
* $second = new TcpServer(8080, $loop);
* $second = new React\Socket\TcpServer(8080, $loop);
* ```
*
* Note that these error conditions may vary depending on your system and/or
Expand All @@ -102,7 +102,7 @@ final class TcpServer extends EventEmitter implements ServerInterface
* for the underlying stream socket resource like this:
*
* ```php
* $server = new TcpServer('[::1]:8080', $loop, array(
* $server = new React\Socket\TcpServer('[::1]:8080', $loop, array(
* 'backlog' => 200,
* 'so_reuseport' => true,
* 'ipv6_v6only' => true
Expand Down
4 changes: 2 additions & 2 deletions src/UnixServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* is responsible for accepting plaintext connections on unix domain sockets.
*
* ```php
* $server = new UnixServer('unix:///tmp/app.sock', $loop);
* $server = new React\Socket\UnixServer('unix:///tmp/app.sock', $loop);
* ```
*
* See also the `ServerInterface` for more details.
Expand All @@ -34,7 +34,7 @@ final class UnixServer extends EventEmitter implements ServerInterface
* for more details.
*
* ```php
* $server = new UnixServer('unix:///tmp/app.sock', $loop);
* $server = new React\Socket\UnixServer('unix:///tmp/app.sock', $loop);
* ```
*
* @param string $path
Expand Down
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