@@ -151,7 +151,7 @@ discard block |
||
| 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 |
||
| 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 | */ |
@@ -22,7 +22,7 @@ |
||
| 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) { |
@@ -52,8 +52,7 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -118,8 +118,7 @@ discard block |
||
| 118 | 118 | $frame |
| 119 | 119 | ); |
| 120 | 120 | } |
| 121 | - } |
|
| 122 | - finally { |
|
| 121 | + } finally { |
|
| 123 | 122 | if ($frame->isFinal()) { |
| 124 | 123 | $this->continue = null; |
| 125 | 124 | } |
@@ -138,11 +137,9 @@ discard block |
||
| 138 | 137 | protected function onControl (Frame $control): void { |
| 139 | 138 | if ($control->isClose()) { |
| 140 | 139 | $this->onClose($control); |
| 141 | - } |
|
| 142 | - elseif ($control->isPing()) { |
|
| 140 | + } elseif ($control->isPing()) { |
|
| 143 | 141 | $this->onPing($control); |
| 144 | - } |
|
| 145 | - elseif ($control->isPong()) { |
|
| 142 | + } elseif ($control->isPong()) { |
|
| 146 | 143 | $this->onPong($control); |
| 147 | 144 | } |
| 148 | 145 | } |
@@ -156,8 +153,7 @@ discard block |
||
| 156 | 153 | $this->onData_SetContinue($data); |
| 157 | 154 | if ($data->isText()) { |
| 158 | 155 | $this->onText($data); |
| 159 | - } |
|
| 160 | - elseif ($data->isBinary()) { |
|
| 156 | + } elseif ($data->isBinary()) { |
|
| 161 | 157 | $this->onBinary($data); |
| 162 | 158 | } |
| 163 | 159 | } |
@@ -188,11 +184,9 @@ discard block |
||
| 188 | 184 | $this->onFrame_CheckLength($frame); |
| 189 | 185 | if ($frame->isControl()) { |
| 190 | 186 | $this->onControl($frame); |
| 191 | - } |
|
| 192 | - elseif ($frame->isContinue()) { |
|
| 187 | + } elseif ($frame->isContinue()) { |
|
| 193 | 188 | $this->onContinue($frame); |
| 194 | - } |
|
| 195 | - else { |
|
| 189 | + } else { |
|
| 196 | 190 | $this->onData($frame); |
| 197 | 191 | } |
| 198 | 192 | } |
@@ -336,12 +330,10 @@ discard block |
||
| 336 | 330 | if ($length > 65535) { |
| 337 | 331 | $head .= chr(127); |
| 338 | 332 | $head .= pack('J', $length); |
| 339 | - } |
|
| 340 | - elseif ($length >= 126) { |
|
| 333 | + } elseif ($length >= 126) { |
|
| 341 | 334 | $head .= chr(126); |
| 342 | 335 | $head .= pack('n', $length); |
| 343 | - } |
|
| 344 | - else { |
|
| 336 | + } else { |
|
| 345 | 337 | $head .= chr($length); |
| 346 | 338 | } |
| 347 | 339 | $this->client->write($head . $payload); |