@@ -93,8 +93,7 @@ |
||
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); |
@@ -91,8 +91,7 @@ discard block |
||
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 |
||
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 | } |
@@ -94,8 +94,7 @@ |
||
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 | } |
@@ -21,8 +21,7 @@ discard block |
||
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 |
||
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 | } |
@@ -65,8 +65,7 @@ |
||
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']}"; |
@@ -52,11 +52,9 @@ |
||
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 | } |
@@ -80,8 +80,7 @@ discard block |
||
80 | 80 | $this->getFrameHandler()->writeClose($code, $reason); |
81 | 81 | $this->shutdown(self::CH_WRITE); |
82 | 82 | } |
83 | - } |
|
84 | - finally { |
|
83 | + } finally { |
|
85 | 84 | $this->state = self::STATE_CLOSE; |
86 | 85 | $this->server->remove($this); |
87 | 86 | parent::close(); |
@@ -173,12 +172,10 @@ discard block |
||
173 | 172 | case self::STATE_CLOSE: |
174 | 173 | return; |
175 | 174 | } |
176 | - } |
|
177 | - catch (WebSocketError $e) { |
|
175 | + } catch (WebSocketError $e) { |
|
178 | 176 | $this->close($e->getCode(), $e->getMessage()); |
179 | 177 | throw $e; |
180 | - } |
|
181 | - catch (Exception $e) { |
|
178 | + } catch (Exception $e) { |
|
182 | 179 | $this->close(Frame::CLOSE_INTERNAL_ERROR); |
183 | 180 | throw $e; |
184 | 181 | } |
@@ -67,11 +67,9 @@ discard block |
||
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 |
||
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 | } |
@@ -21,8 +21,7 @@ |
||
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 | } |