Passed
Push — master ( a91d54...875978 )
by y
02:08
created
src/AbstractSocket.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -61,11 +61,9 @@  discard block
 block discarded – undo
61 61
     public function __construct ($resource) {
62 62
         if (!is_resource($resource) or get_resource_type($resource) !== 'Socket') {
63 63
             throw new InvalidArgumentException('Expected an open socket resource.', SOCKET_EBADF);
64
-        }
65
-        elseif (socket_get_option($resource, SOL_SOCKET, SO_TYPE) !== static::getType()) {
64
+        } elseif (socket_get_option($resource, SOL_SOCKET, SO_TYPE) !== static::getType()) {
66 65
             throw new InvalidArgumentException('The given socket resource is of the wrong type for ' . get_class(), SOCKET_ESOCKTNOSUPPORT);
67
-        }
68
-        elseif ($errno = SocketError::getLast($resource)) {
66
+        } elseif ($errno = SocketError::getLast($resource)) {
69 67
             $error = new SocketError(SOCKET_EBADFD);
70 68
             $error->setExtra($errno);
71 69
             throw $error;
@@ -289,8 +287,7 @@  discard block
 block discarded – undo
289 287
     public function setBlocking ($blocking) {
290 288
         if ($blocking) {
291 289
             $success = @socket_set_block($this->resource);
292
-        }
293
-        else {
290
+        } else {
294 291
             $success = @socket_set_nonblock($this->resource);
295 292
         }
296 293
         if (!$success) {
Please login to merge, or discard this patch.
src/StreamClient.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,8 +53,7 @@  discard block
 block discarded – undo
53 53
                 $length -= $chunkSize = strlen($chunk);
54 54
             } while ($chunkSize and $length);
55 55
             return $data;
56
-        }
57
-        catch (SocketError $error) {
56
+        } catch (SocketError $error) {
58 57
             $error->setExtra($data);
59 58
             throw $error;
60 59
         }
@@ -90,8 +89,7 @@  discard block
 block discarded – undo
90 89
         $length = $this->getOption(SO_RCVBUF);
91 90
         try {
92 91
             return $this->recv($length, $msgFlags);
93
-        }
94
-        catch (SocketError $e) {
92
+        } catch (SocketError $e) {
95 93
             if ($e->getCode() === SOCKET_EAGAIN) { // would block
96 94
                 return '';
97 95
             }
Please login to merge, or discard this patch.
src/Reactor.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -93,8 +93,7 @@
 block discarded – undo
93 93
             foreach ($rwe[0] as $id => $socket) {
94 94
                 $socket->onReadable();
95 95
             }
96
-        }
97
-        finally {
96
+        } finally {
98 97
             array_walk_recursive($rwe, function(ReactiveInterface $each) {
99 98
                 if (!$each->isOpen()) {
100 99
                     $this->remove($each);
Please login to merge, or discard this patch.
src/AbstractServer.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,8 +19,7 @@
 block discarded – undo
19 19
     public function __toString () {
20 20
         try {
21 21
             return implode(':', $this->getSockName());
22
-        }
23
-        catch (Exception $exception) {
22
+        } catch (Exception $exception) {
24 23
             return ':';
25 24
         }
26 25
     }
Please login to merge, or discard this patch.
src/AbstractClient.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,8 +19,7 @@  discard block
 block discarded – undo
19 19
     public function __toString () {
20 20
         try {
21 21
             return implode(':', $this->getPeerName());
22
-        }
23
-        catch (Exception $exception) {
22
+        } catch (Exception $exception) {
24 23
             return ':';
25 24
         }
26 25
     }
@@ -102,8 +101,7 @@  discard block
 block discarded – undo
102 101
         while ($total < $length) {
103 102
             try {
104 103
                 $total += $this->awaitWritable()->send(substr($data, $total));
105
-            }
106
-            catch (SocketError $error) {
104
+            } catch (SocketError $error) {
107 105
                 $error->setExtra($total);
108 106
                 throw $error;
109 107
             }
Please login to merge, or discard this patch.
src/WebSocket/HandShake.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -91,8 +91,7 @@  discard block
 block discarded – undo
91 91
                 $value = trim($value);
92 92
                 if (isset($this->headers[$key])) {
93 93
                     $this->headers[$key] .= ', ' . $value;
94
-                }
95
-                else {
94
+                } else {
96 95
                     $this->headers[$key] = $value;
97 96
                 }
98 97
             }
@@ -101,8 +100,7 @@  discard block
 block discarded – undo
101 100
             $this->upgrade();
102 101
             $this->client->write("\r\n\r\n");
103 102
             return true;
104
-        }
105
-        catch (WebSocketError $e) {
103
+        } catch (WebSocketError $e) {
106 104
             $this->client->write("HTTP/1.1 {$e->getCode()}\r\n\r\n");
107 105
             throw $e;
108 106
         }
Please login to merge, or discard this patch.
src/WebSocket/WebSocketServer.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -94,8 +94,7 @@
 block discarded – undo
94 94
         foreach ($this->clients as $client) {
95 95
             try {
96 96
                 $client->close($code, $reason);
97
-            }
98
-            catch (Exception $e) {
97
+            } catch (Exception $e) {
99 98
                 continue;
100 99
             }
101 100
         }
Please login to merge, or discard this patch.
src/WebSocket/WebSocketClient.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -81,8 +81,7 @@  discard block
 block discarded – undo
81 81
                 $this->getFrameHandler()->write($payload, Frame::OP_CLOSE);
82 82
                 $this->shutdown(self::CH_WRITE);
83 83
             }
84
-        }
85
-        finally {
84
+        } finally {
86 85
             $this->state = self::STATE_CLOSE;
87 86
             $this->server->remove($this);
88 87
             parent::close();
@@ -174,12 +173,10 @@  discard block
 block discarded – undo
174 173
                 case self::STATE_CLOSE:
175 174
                     return;
176 175
             }
177
-        }
178
-        catch (WebSocketError $e) {
176
+        } catch (WebSocketError $e) {
179 177
             $this->close($e->getCode(), $e->getMessage());
180 178
             throw $e;
181
-        }
182
-        catch (Exception $e) {
179
+        } catch (Exception $e) {
183 180
             $this->close(Frame::CLOSE_INTERNAL_ERROR);
184 181
             throw $e;
185 182
         }
Please login to merge, or discard this patch.
src/WebSocket/FrameHandler.php 1 patch
Braces   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -48,8 +48,7 @@  discard block
 block discarded – undo
48 48
         $handler = $this->client->getMessageHandler();
49 49
         if ($handler->isBinaryStream()) {
50 50
             $handler->onBinary($binary->getPayload());
51
-        }
52
-        else {
51
+        } else {
53 52
             if (strlen($this->binary) + $binary->getLength() > $handler->getMaxLength()) {
54 53
                 throw new WebSocketError(Frame::CLOSE_TOO_LARGE, $handler->getMaxLength(), $binary);
55 54
             }
@@ -111,11 +110,9 @@  discard block
 block discarded – undo
111 110
     protected function onControl (Frame $control): void {
112 111
         if ($control->isClose()) {
113 112
             $this->onClose($control);
114
-        }
115
-        elseif ($control->isPing()) {
113
+        } elseif ($control->isPing()) {
116 114
             $this->onPing($control);
117
-        }
118
-        elseif ($control->isPong()) {
115
+        } elseif ($control->isPong()) {
119 116
             $this->onPong($control);
120 117
         }
121 118
     }
@@ -128,8 +125,7 @@  discard block
 block discarded – undo
128 125
     protected function onData (Frame $data): void {
129 126
         if ($data->isText()) {
130 127
             $this->onText($data);
131
-        }
132
-        elseif ($data->isBinary()) {
128
+        } elseif ($data->isBinary()) {
133 129
             $this->onBinary($data);
134 130
         }
135 131
     }
@@ -146,11 +142,9 @@  discard block
 block discarded – undo
146 142
         $frame->validate();
147 143
         if ($frame->isControl()) {
148 144
             $this->onControl($frame);
149
-        }
150
-        elseif ($frame->isContinue()) {
145
+        } elseif ($frame->isContinue()) {
151 146
             $this->onContinue($frame);
152
-        }
153
-        else {
147
+        } else {
154 148
             $this->onData($frame);
155 149
         }
156 150
     }
@@ -200,8 +194,7 @@  discard block
 block discarded – undo
200 194
         $handler = $this->client->getMessageHandler();
201 195
         if ($handler->isTextStream()) {
202 196
             $handler->onText($text->getPayload());
203
-        }
204
-        else {
197
+        } else {
205 198
             if (strlen($this->text) + $text->getLength() > $handler->getMaxLength()) {
206 199
                 throw new WebSocketError(Frame::CLOSE_TOO_LARGE, $handler->getMaxLength(), $text);
207 200
             }
@@ -227,12 +220,10 @@  discard block
 block discarded – undo
227 220
         if ($length > 65535) {
228 221
             $head .= chr(127);
229 222
             $head .= pack('J', $length);
230
-        }
231
-        elseif ($length >= 126) {
223
+        } elseif ($length >= 126) {
232 224
             $head .= chr(126);
233 225
             $head .= pack('n', $length);
234
-        }
235
-        else {
226
+        } else {
236 227
             $head .= chr($length);
237 228
         }
238 229
         $this->client->write($head . $payload);
Please login to merge, or discard this patch.