Completed
Push — master ( 1f28ab...083bb9 )
by y
01:17
created
src/AbstractClient.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,8 +21,7 @@  discard block
 block discarded – undo
21 21
     public function __toString () {
22 22
         try {
23 23
             return implode(':', $this->getPeerName());
24
-        }
25
-        catch (Throwable $e) {
24
+        } catch (Throwable $e) {
26 25
             return "?{$this->resource}";
27 26
         }
28 27
     }
@@ -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 $e) {
104
+            } catch (SocketError $e) {
107 105
                 $e->setExtra($total);
108 106
                 throw $e;
109 107
             }
Please login to merge, or discard this patch.
src/SocketError.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -65,8 +65,7 @@
 block discarded – undo
65 65
     public function __construct ($subject = null, $fallback = 0, SocketError $previous = null) {
66 66
         if ($errno = is_int($subject) ? $subject : static::getLast($subject)) {
67 67
             $message = socket_strerror($errno);
68
-        }
69
-        else {
68
+        } else {
70 69
             $errno = $fallback;
71 70
             $last = error_get_last();
72 71
             $message = "{$last['message']} in {$last['file']}:{$last['line']}";
Please login to merge, or discard this patch.
src/AbstractSocket.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -52,11 +52,9 @@
 block discarded – undo
52 52
     public function __construct ($resource) {
53 53
         if (!is_resource($resource) or get_resource_type($resource) !== 'Socket') {
54 54
             throw new InvalidArgumentException('Expected an open socket resource.', SOCKET_EBADF);
55
-        }
56
-        elseif (socket_get_option($resource, SOL_SOCKET, SO_TYPE) !== static::getType()) {
55
+        } elseif (socket_get_option($resource, SOL_SOCKET, SO_TYPE) !== static::getType()) {
57 56
             throw new InvalidArgumentException('Invalid socket type for ' . static::class, SOCKET_ESOCKTNOSUPPORT);
58
-        }
59
-        elseif ($errno = SocketError::getLast($resource)) {
57
+        } elseif ($errno = SocketError::getLast($resource)) {
60 58
             // "File descriptor in bad state"
61 59
             throw new SocketError(SOCKET_EBADFD, 0, new SocketError($errno));
62 60
         }
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
@@ -21,8 +21,7 @@
 block discarded – undo
21 21
     public function __toString () {
22 22
         try {
23 23
             return implode(':', $this->getSockName());
24
-        }
25
-        catch (Throwable $e) {
24
+        } catch (Throwable $e) {
26 25
             return "?{$this->resource}";
27 26
         }
28 27
     }
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
@@ -52,8 +52,7 @@  discard block
 block discarded – undo
52 52
                 $length -= $chunkSize = strlen($chunk);
53 53
             } while ($chunkSize and $length);
54 54
             return $data;
55
-        }
56
-        catch (SocketError $e) {
55
+        } catch (SocketError $e) {
57 56
             $e->setExtra($data);
58 57
             throw $e;
59 58
         }
@@ -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, $flags);
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   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -84,8 +84,7 @@  discard block
 block discarded – undo
84 84
         unset($channel);
85 85
         if ($socket instanceof WebSocketClient and $error instanceof WebSocketError) {
86 86
             $socket->close($error->getCode(), $error->getMessage());
87
-        }
88
-        else {
87
+        } else {
89 88
             $socket->close();
90 89
         }
91 90
         echo $error;
@@ -109,11 +108,9 @@  discard block
 block discarded – undo
109 108
             foreach ($rwe[$channel] as $id => $socket) {
110 109
                 try {
111 110
                     $socket->{$method}();
112
-                }
113
-                catch (Throwable $error) {
111
+                } catch (Throwable $error) {
114 112
                     $this->onError($channel, $socket, $error);
115
-                }
116
-                finally {
113
+                } finally {
117 114
                     if (!$socket->isOpen()) {
118 115
                         $this->remove($socket);
119 116
                     }
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
@@ -101,8 +101,7 @@
 block discarded – undo
101 101
         foreach ($this->clients as $client) {
102 102
             try {
103 103
                 $client->close($code, $reason); // clients remove themselves
104
-            }
105
-            catch (Exception $e) {
104
+            } catch (Exception $e) {
106 105
                 continue;
107 106
             }
108 107
         }
Please login to merge, or discard this patch.
src/WebSocket/Handshake.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -101,19 +101,16 @@
 block discarded – undo
101 101
                 $value = trim($value);
102 102
                 if (isset($this->headers[$key])) {
103 103
                     $this->headers[$key] .= ', ' . $value;
104
-                }
105
-                else {
104
+                } else {
106 105
                     $this->headers[$key] = $value;
107 106
                 }
108 107
             }
109 108
             $this->buffer = ''; // wipe the buffer
110 109
             $this->validate();
111
-        }
112
-        catch (WebSocketError $e) { // catch and respond with HTTP error and rethrow
110
+        } catch (WebSocketError $e) { // catch and respond with HTTP error and rethrow
113 111
             $this->client->write("HTTP/1.1 {$e->getCode()} WebSocket Handshake Failure\r\n\r\n");
114 112
             throw $e;
115
-        }
116
-        catch (Throwable $e) { // catch everything else and respond with HTTP 500 and rethrow
113
+        } catch (Throwable $e) { // catch everything else and respond with HTTP 500 and rethrow
117 114
             $this->client->write("HTTP/1.1 500 WebSocket Internal Error\r\n\r\n");
118 115
             throw $e;
119 116
         }
Please login to merge, or discard this patch.
src/WebSocket/WebSocketClient.php 1 patch
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -82,8 +82,7 @@  discard block
 block discarded – undo
82 82
             if ($code >= 1000 and $this->isOk()) {
83 83
                 $this->frameHandler->writeClose($code, $reason);
84 84
             }
85
-        }
86
-        finally {
85
+        } finally {
87 86
             $this->server->remove($this);
88 87
             parent::close();
89 88
             $this->state = self::STATE_CLOSED;
@@ -200,16 +199,13 @@  discard block
 block discarded – undo
200 199
                     $this->state = self::STATE_OK;
201 200
                     $this->onStateOk();
202 201
                 }
203
-            }
204
-            elseif ($this->isOk()) {
202
+            } elseif ($this->isOk()) {
205 203
                 $this->frameHandler->onReadable();
206 204
             }
207
-        }
208
-        catch (WebSocketError $e) {
205
+        } catch (WebSocketError $e) {
209 206
             $this->close($e->getCode(), $e->getMessage());
210 207
             throw $e;
211
-        }
212
-        catch (Throwable $e) {
208
+        } catch (Throwable $e) {
213 209
             $this->close(Frame::CLOSE_INTERNAL_ERROR);
214 210
             throw $e;
215 211
         }
Please login to merge, or discard this patch.