Completed
Push — master ( 9fb81f...0a022c )
by y
01:28
created
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/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 2 patches
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.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
      * @see https://php.net/socket_get_option
152 152
      *
153 153
      * @param int $option `SO_*` option constant.
154
-     * @return mixed The option's value. This is never `false`.
154
+     * @return integer The option's value. This is never `false`.
155 155
      * @throws SocketError
156 156
      */
157 157
     public function getOption (int $option) {
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
      * @see await()
214 214
      *
215 215
      * @param int $channel `SocketInterface` channel constant.
216
-     * @param float|null $timeout Maximum seconds to block. `NULL` blocks forever. Defaults to a poll.
216
+     * @param integer $timeout Maximum seconds to block. `NULL` blocks forever. Defaults to a poll.
217 217
      * @return bool
218 218
      * @throws SocketError
219 219
      */
Please login to merge, or discard this patch.
src/WebSocket/FrameReader.php 2 patches
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -67,11 +67,9 @@  discard block
 block discarded – undo
67 67
                 ];
68 68
                 $this->buffer = substr($this->buffer, strlen($head[0]));
69 69
                 $this->validate();
70
-            }
71
-            elseif (strlen($this->buffer) >= 14) { // max head room
70
+            } elseif (strlen($this->buffer) >= 14) { // max head room
72 71
                 throw new WebSocketError(Frame::CLOSE_PROTOCOL_ERROR, 'Bad frame.');
73
-            }
74
-            else {
72
+            } else {
75 73
                 return null;
76 74
             }
77 75
         }
@@ -139,8 +137,7 @@  discard block
 block discarded – undo
139 137
             if (!$this->head['final']) {
140 138
                 throw new WebSocketError(Frame::CLOSE_PROTOCOL_ERROR, "Received fragmented {$name}");
141 139
             }
142
-        }
143
-        elseif ($opCode > Frame::OP_BINARY) { // data
140
+        } elseif ($opCode > Frame::OP_BINARY) { // data
144 141
             throw new WebSocketError(Frame::CLOSE_PROTOCOL_ERROR, "Received {$name}");
145 142
         }
146 143
     }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@
 block discarded – undo
97 97
     /**
98 98
      * Yields all available frames from the peer.
99 99
      *
100
-     * @return Generator|Frame[]
100
+     * @return Generator
101 101
      */
102 102
     public function getFrames () {
103 103
         $this->buffer .= $this->client->recvAll();
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 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
      * @see https://php.net/socket_create_pair
23 23
      *
24 24
      * @param array $extra Variadic constructor arguments.
25
-     * @return static[] Two instances at indices `0` and `1`.
25
+     * @return StreamClient[] Two instances at indices `0` and `1`.
26 26
      * @throws SocketError
27 27
      */
28 28
     public static function newUnixPair (...$extra) {
Please login to merge, or discard this 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/WebSocketClient.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -88,8 +88,7 @@  discard block
 block discarded – undo
88 88
             if ($code >= 1000 and $this->isOk()) {
89 89
                 $this->frameHandler->writeClose($code, $reason);
90 90
             }
91
-        }
92
-        finally {
91
+        } finally {
93 92
             $this->server->remove($this);
94 93
             parent::close();
95 94
             $this->state = self::STATE_CLOSED;
@@ -216,12 +215,10 @@  discard block
 block discarded – undo
216 215
                 case self::STATE_CLOSED:
217 216
                     return;
218 217
             }
219
-        }
220
-        catch (WebSocketError $e) {
218
+        } catch (WebSocketError $e) {
221 219
             $this->close($e->getCode(), $e->getMessage());
222 220
             throw $e;
223
-        }
224
-        catch (Throwable $e) {
221
+        } catch (Throwable $e) {
225 222
             $this->close(Frame::CLOSE_INTERNAL_ERROR);
226 223
             throw $e;
227 224
         }
Please login to merge, or discard this patch.