@@ -142,10 +142,10 @@ discard block |
||
| 142 | 142 | $this->context = $context; |
| 143 | 143 | |
| 144 | 144 | $that = $this; |
| 145 | - $this->tcp->on('connection', function ($connection) use ($that) { |
|
| 145 | + $this->tcp->on('connection', function($connection) use ($that) { |
|
| 146 | 146 | $that->handleConnection($connection); |
| 147 | 147 | }); |
| 148 | - $this->tcp->on('error', function ($error) use ($that) { |
|
| 148 | + $this->tcp->on('error', function($error) use ($that) { |
|
| 149 | 149 | $that->emit('error', array($error)); |
| 150 | 150 | }); |
| 151 | 151 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | return null; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - return \str_replace('tcp://' , 'tls://', $address); |
|
| 160 | + return \str_replace('tcp://', 'tls://', $address); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | public function pause() |
@@ -193,10 +193,10 @@ discard block |
||
| 193 | 193 | $that = $this; |
| 194 | 194 | |
| 195 | 195 | $this->encryption->enable($connection)->then( |
| 196 | - function ($conn) use ($that) { |
|
| 196 | + function($conn) use ($that) { |
|
| 197 | 197 | $that->emit('connection', array($conn)); |
| 198 | 198 | }, |
| 199 | - function ($error) use ($that, $connection, $remote) { |
|
| 199 | + function($error) use ($that, $connection, $remote) { |
|
| 200 | 200 | $error = new \RuntimeException( |
| 201 | 201 | 'Connection from ' . $remote . ' failed during TLS handshake: ' . $error->getMessage(), |
| 202 | 202 | $error->getCode() |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | $this->loop = $loop ?: Loop::get(); |
| 138 | 138 | |
| 139 | 139 | // a single port has been given => assume localhost |
| 140 | - if ((string)(int)$uri === (string)$uri) { |
|
| 140 | + if ((string) (int) $uri === (string) $uri) { |
|
| 141 | 141 | $uri = '127.0.0.1:' . $uri; |
| 142 | 142 | } |
| 143 | 143 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | $that = $this; |
| 232 | - $this->loop->addReadStream($this->master, function ($master) use ($that) { |
|
| 232 | + $this->loop->addReadStream($this->master, function($master) use ($that) { |
|
| 233 | 233 | try { |
| 234 | 234 | $newSocket = SocketServer::accept($master); |
| 235 | 235 | } catch (\RuntimeException $e) { |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | /** @var \React\Promise\PromiseInterface<ConnectionInterface> $promise */ |
| 56 | 56 | $promise = $this->connector->connect( |
| 57 | 57 | \str_replace('tls://', '', $uri) |
| 58 | - )->then(function (ConnectionInterface $connection) use ($context, $encryption, $uri, &$promise, &$connected) { |
|
| 58 | + )->then(function(ConnectionInterface $connection) use ($context, $encryption, $uri, &$promise, &$connected) { |
|
| 59 | 59 | // (unencrypted) TCP/IP connection succeeded |
| 60 | 60 | $connected = true; |
| 61 | 61 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // try to enable encryption |
| 73 | - return $promise = $encryption->enable($connection)->then(null, function ($error) use ($connection, $uri) { |
|
| 73 | + return $promise = $encryption->enable($connection)->then(null, function($error) use ($connection, $uri) { |
|
| 74 | 74 | // establishing encryption failed => close invalid connection and return error |
| 75 | 75 | $connection->close(); |
| 76 | 76 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $error->getCode() |
| 80 | 80 | ); |
| 81 | 81 | }); |
| 82 | - }, function (\Exception $e) use ($uri) { |
|
| 82 | + }, function(\Exception $e) use ($uri) { |
|
| 83 | 83 | if ($e instanceof \RuntimeException) { |
| 84 | 84 | $message = \preg_replace('/^Connection to [^ ]+/', '', $e->getMessage()); |
| 85 | 85 | $e = new \RuntimeException( |
@@ -113,10 +113,10 @@ discard block |
||
| 113 | 113 | }); |
| 114 | 114 | |
| 115 | 115 | return new \React\Promise\Promise( |
| 116 | - function ($resolve, $reject) use ($promise) { |
|
| 116 | + function($resolve, $reject) use ($promise) { |
|
| 117 | 117 | $promise->then($resolve, $reject); |
| 118 | 118 | }, |
| 119 | - function ($_, $reject) use (&$promise, $uri, &$connected) { |
|
| 119 | + function($_, $reject) use (&$promise, $uri, &$connected) { |
|
| 120 | 120 | if ($connected) { |
| 121 | 121 | $reject(new \RuntimeException( |
| 122 | 122 | 'Connection to ' . $uri . ' cancelled during TLS handshake (ECONNABORTED)', |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | // TODO: add write() event to make sure we're not sending any excessive data |
| 67 | 67 | |
| 68 | 68 | // cancelling this leaves this stream in an inconsistent state… |
| 69 | - $deferred = new Deferred(function () { |
|
| 69 | + $deferred = new Deferred(function() { |
|
| 70 | 70 | throw new \RuntimeException(); |
| 71 | 71 | }); |
| 72 | 72 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | $that = $this; |
| 84 | - $toggleCrypto = function () use ($socket, $deferred, $toggle, $method, $that) { |
|
| 84 | + $toggleCrypto = function() use ($socket, $deferred, $toggle, $method, $that) { |
|
| 85 | 85 | $that->toggleCrypto($socket, $deferred, $toggle, $method); |
| 86 | 86 | }; |
| 87 | 87 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | $loop = $this->loop; |
| 95 | 95 | |
| 96 | - return $deferred->promise()->then(function () use ($stream, $socket, $loop, $toggle) { |
|
| 96 | + return $deferred->promise()->then(function() use ($stream, $socket, $loop, $toggle) { |
|
| 97 | 97 | $loop->removeReadStream($socket); |
| 98 | 98 | |
| 99 | 99 | $stream->encryptionEnabled = $toggle; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | public function toggleCrypto($socket, Deferred $deferred, $toggle, $method) |
| 119 | 119 | { |
| 120 | 120 | $error = null; |
| 121 | - \set_error_handler(function ($_, $errstr) use (&$error) { |
|
| 121 | + \set_error_handler(function($_, $errstr) use (&$error) { |
|
| 122 | 122 | $error = \str_replace(array("\r", "\n"), ' ', $errstr); |
| 123 | 123 | |
| 124 | 124 | // remove useless function name from error message |
@@ -34,15 +34,15 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | $loop = $this->loop; |
| 36 | 36 | $time = $this->timeout; |
| 37 | - return new Promise(function ($resolve, $reject) use ($loop, $time, $promise, $uri) { |
|
| 37 | + return new Promise(function($resolve, $reject) use ($loop, $time, $promise, $uri) { |
|
| 38 | 38 | $timer = null; |
| 39 | - $promise = $promise->then(function ($v) use (&$timer, $loop, $resolve) { |
|
| 39 | + $promise = $promise->then(function($v) use (&$timer, $loop, $resolve) { |
|
| 40 | 40 | if ($timer) { |
| 41 | 41 | $loop->cancelTimer($timer); |
| 42 | 42 | } |
| 43 | 43 | $timer = false; |
| 44 | 44 | $resolve($v); |
| 45 | - }, function ($v) use (&$timer, $loop, $reject) { |
|
| 45 | + }, function($v) use (&$timer, $loop, $reject) { |
|
| 46 | 46 | if ($timer) { |
| 47 | 47 | $loop->cancelTimer($timer); |
| 48 | 48 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | // start timeout timer which will cancel the pending promise |
| 59 | - $timer = $loop->addTimer($time, function () use ($time, &$promise, $reject, $uri) { |
|
| 59 | + $timer = $loop->addTimer($time, function() use ($time, &$promise, $reject, $uri) { |
|
| 60 | 60 | $reject(new \RuntimeException( |
| 61 | 61 | 'Connection to ' . $uri . ' timed out after ' . $time . ' seconds (ETIMEDOUT)', |
| 62 | 62 | \defined('SOCKET_ETIMEDOUT') ? \SOCKET_ETIMEDOUT : 110 |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $promise->cancel(); |
| 69 | 69 | $promise = null; |
| 70 | 70 | }); |
| 71 | - }, function () use (&$promise) { |
|
| 71 | + }, function() use (&$promise) { |
|
| 72 | 72 | // Cancelling this promise will cancel the pending connection, thus triggering the rejection logic above. |
| 73 | 73 | // Avoid garbage references in call stack by passing pending promise by reference. |
| 74 | 74 | assert(\method_exists($promise, 'cancel')); |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | // wait for connection |
| 108 | 108 | $loop = $this->loop; |
| 109 | - return new Promise\Promise(function ($resolve, $reject) use ($loop, $stream, $uri) { |
|
| 110 | - $loop->addWriteStream($stream, function ($stream) use ($loop, $resolve, $reject, $uri) { |
|
| 109 | + return new Promise\Promise(function($resolve, $reject) use ($loop, $stream, $uri) { |
|
| 110 | + $loop->addWriteStream($stream, function($stream) use ($loop, $resolve, $reject, $uri) { |
|
| 111 | 111 | $loop->removeWriteStream($stream); |
| 112 | 112 | |
| 113 | 113 | // The following hack looks like the only way to |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | // This is only known to work on Linux, Mac and Windows are known to not support this. |
| 127 | 127 | $errno = 0; |
| 128 | 128 | $errstr = ''; |
| 129 | - \set_error_handler(function ($_, $error) use (&$errno, &$errstr) { |
|
| 129 | + \set_error_handler(function($_, $error) use (&$errno, &$errstr) { |
|
| 130 | 130 | // Match errstr from PHP's warning message. |
| 131 | 131 | // fwrite(): send of 1 bytes failed with errno=111 Connection refused |
| 132 | 132 | \preg_match('/errno=(\d+) (.+)/', $error, $m); |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | $resolve(new Connection($stream, $loop)); |
| 154 | 154 | } |
| 155 | 155 | }); |
| 156 | - }, function () use ($loop, $stream, $uri) { |
|
| 156 | + }, function() use ($loop, $stream, $uri) { |
|
| 157 | 157 | $loop->removeWriteStream($stream); |
| 158 | 158 | \fclose($stream); |
| 159 | 159 | |
@@ -72,10 +72,10 @@ discard block |
||
| 72 | 72 | $this->server = $server; |
| 73 | 73 | |
| 74 | 74 | $that = $this; |
| 75 | - $server->on('connection', function (ConnectionInterface $conn) use ($that) { |
|
| 75 | + $server->on('connection', function(ConnectionInterface $conn) use ($that) { |
|
| 76 | 76 | $that->emit('connection', array($conn)); |
| 77 | 77 | }); |
| 78 | - $server->on('error', function (\Exception $error) use ($that) { |
|
| 78 | + $server->on('error', function(\Exception $error) use ($that) { |
|
| 79 | 79 | $that->emit('error', array($error)); |
| 80 | 80 | }); |
| 81 | 81 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | { |
| 113 | 113 | $errno = 0; |
| 114 | 114 | $errstr = ''; |
| 115 | - \set_error_handler(function ($_, $error) use (&$errno, &$errstr) { |
|
| 115 | + \set_error_handler(function($_, $error) use (&$errno, &$errstr) { |
|
| 116 | 116 | // Match errstr from PHP's warning message. |
| 117 | 117 | // stream_socket_accept(): accept failed: Connection timed out |
| 118 | 118 | $errstr = \preg_replace('#.*: #', '', $error); |
@@ -164,7 +164,7 @@ |
||
| 164 | 164 | |
| 165 | 165 | $this->connections[] = $connection; |
| 166 | 166 | $that = $this; |
| 167 | - $connection->on('close', function () use ($that, $connection) { |
|
| 167 | + $connection->on('close', function() use ($that, $connection) { |
|
| 168 | 168 | $that->handleDisconnection($connection); |
| 169 | 169 | }); |
| 170 | 170 | |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | // parse string into array structure |
| 40 | 40 | // ignore warnings due to excessive data structures (max_input_vars and max_input_nesting_level) |
| 41 | 41 | $ret = array(); |
| 42 | - @\parse_str((string)$request->getBody(), $ret); |
|
| 42 | + @\parse_str((string) $request->getBody(), $ret); |
|
| 43 | 43 | |
| 44 | 44 | return $request->withParsedBody($ret); |
| 45 | 45 | } |