@@ -52,8 +52,7 @@ |
||
| 52 | 52 | if ($chunk === '') { |
| 53 | 53 | return $data; |
| 54 | 54 | } |
| 55 | - } |
|
| 56 | - catch (Error $error) { |
|
| 55 | + } catch (Error $error) { |
|
| 57 | 56 | $error->setExtra($data); |
| 58 | 57 | throw $error; |
| 59 | 58 | } |
@@ -96,11 +96,9 @@ discard block |
||
| 96 | 96 | public function __construct ($resource) { |
| 97 | 97 | if (!is_resource($resource) or get_resource_type($resource) !== 'Socket') { |
| 98 | 98 | throw new InvalidArgumentException('Expected an open socket resource.', SOCKET_EBADF); |
| 99 | - } |
|
| 100 | - elseif (socket_get_option($resource, SOL_SOCKET, SO_TYPE) !== static::getType()) { |
|
| 99 | + } elseif (socket_get_option($resource, SOL_SOCKET, SO_TYPE) !== static::getType()) { |
|
| 101 | 100 | throw new InvalidArgumentException('The given socket resource is of the wrong type for ' . get_class(), SOCKET_ESOCKTNOSUPPORT); |
| 102 | - } |
|
| 103 | - elseif ($errno = Error::getLast($resource)) { |
|
| 101 | + } elseif ($errno = Error::getLast($resource)) { |
|
| 104 | 102 | $error = new Error(SOCKET_EBADFD); |
| 105 | 103 | $error->setExtra($errno); |
| 106 | 104 | throw $error; |
@@ -331,8 +329,7 @@ discard block |
||
| 331 | 329 | public function setBlocking ($blocking) { |
| 332 | 330 | if ($blocking) { |
| 333 | 331 | $success = @socket_set_block($this->resource); |
| 334 | - } |
|
| 335 | - else { |
|
| 332 | + } else { |
|
| 336 | 333 | $success = @socket_set_nonblock($this->resource); |
| 337 | 334 | } |
| 338 | 335 | if (!$success) { |
@@ -57,14 +57,12 @@ |
||
| 57 | 57 | public function __construct ($subject = null, $fallback = 0) { |
| 58 | 58 | if (is_int($subject)) { |
| 59 | 59 | $errno = $subject; |
| 60 | - } |
|
| 61 | - else { |
|
| 60 | + } else { |
|
| 62 | 61 | $errno = static::getLast($subject); |
| 63 | 62 | } |
| 64 | 63 | if ($errno) { |
| 65 | 64 | $message = socket_strerror($errno); |
| 66 | - } |
|
| 67 | - else { |
|
| 65 | + } else { |
|
| 68 | 66 | $errno = $fallback; |
| 69 | 67 | $message = error_get_last()['message']; |
| 70 | 68 | } |
@@ -17,8 +17,7 @@ |
||
| 17 | 17 | public function __toString () { |
| 18 | 18 | try { |
| 19 | 19 | return implode(':', $this->getSockName()); |
| 20 | - } |
|
| 21 | - catch (\Exception $exception) { |
|
| 20 | + } catch (\Exception $exception) { |
|
| 22 | 21 | return ':'; |
| 23 | 22 | } |
| 24 | 23 | } |
@@ -31,12 +31,10 @@ |
||
| 31 | 31 | if ($len > 65535) { |
| 32 | 32 | $frame .= chr(127); |
| 33 | 33 | $frame .= pack('J', $len); |
| 34 | - } |
|
| 35 | - elseif ($len >= 126) { |
|
| 34 | + } elseif ($len >= 126) { |
|
| 36 | 35 | $frame .= chr(126); |
| 37 | 36 | $frame .= pack('n', $len); |
| 38 | - } |
|
| 39 | - else { |
|
| 37 | + } else { |
|
| 40 | 38 | $frame .= chr($len); |
| 41 | 39 | } |
| 42 | 40 | return $frame . $payload; |
@@ -57,14 +57,11 @@ |
||
| 57 | 57 | $frame = new WebSocketFrame($data); |
| 58 | 58 | if ($frame->isText()) { |
| 59 | 59 | $this->onText($frame->getPayload()); |
| 60 | - } |
|
| 61 | - elseif ($frame->isBinary()) { |
|
| 60 | + } elseif ($frame->isBinary()) { |
|
| 62 | 61 | $this->onData($frame->getPayload()); |
| 63 | - } |
|
| 64 | - elseif ($frame->isPong()) { |
|
| 62 | + } elseif ($frame->isPong()) { |
|
| 65 | 63 | $this->onPong(); |
| 66 | - } |
|
| 67 | - elseif ($frame->isClose()) { |
|
| 64 | + } elseif ($frame->isClose()) { |
|
| 68 | 65 | $this->close(); |
| 69 | 66 | } |
| 70 | 67 | } |
@@ -19,8 +19,7 @@ discard block |
||
| 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 | } |
@@ -109,8 +108,7 @@ discard block |
||
| 109 | 108 | try { |
| 110 | 109 | $total += $count = $this->await(self::CH_WRITE)->send($data); |
| 111 | 110 | $data = substr($data, $count); // 0 bytes sent = unaltered buffer |
| 112 | - } |
|
| 113 | - catch (Error $error) { |
|
| 111 | + } catch (Error $error) { |
|
| 114 | 112 | $error->setExtra($total); |
| 115 | 113 | throw $error; |
| 116 | 114 | } |