@@ -10,7 +10,7 @@ |
||
| 10 | 10 | /** |
| 11 | 11 | * @return int `SOCK_DGRAM` |
| 12 | 12 | */ |
| 13 | - final public static function getType () { |
|
| 13 | + final public static function getType() { |
|
| 14 | 14 | return SOCK_DGRAM; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @return string |
| 16 | 16 | */ |
| 17 | - public function __toString () { |
|
| 17 | + public function __toString() { |
|
| 18 | 18 | try { |
| 19 | 19 | return implode(':', $this->getSockName()); |
| 20 | 20 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * @throws Error |
| 37 | 37 | * @return $this |
| 38 | 38 | */ |
| 39 | - public function bind ($address, $port = 0) { |
|
| 39 | + public function bind($address, $port = 0) { |
|
| 40 | 40 | if (!@socket_bind($this->resource, $address, $port)) { |
| 41 | 41 | throw new Error($this->resource, SOCKET_EOPNOTSUPP); |
| 42 | 42 | } |
@@ -17,8 +17,7 @@ |
||
| 17 | 17 | public function __toString () { |
| 18 | 18 | try { |
| 19 | 19 | return implode(':', $this->getSockName()); |
| 20 | - } |
|
| 21 | - catch (\Exception $e) { |
|
| 20 | + } catch (\Exception $e) { |
|
| 22 | 21 | return ':'; |
| 23 | 22 | } |
| 24 | 23 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | * @param ReactiveInterface $socket |
| 23 | 23 | * @return $this |
| 24 | 24 | */ |
| 25 | - public function add (ReactiveInterface $socket) { |
|
| 25 | + public function add(ReactiveInterface $socket) { |
|
| 26 | 26 | $this->sockets[$socket->getId()] = $socket; |
| 27 | 27 | return $this; |
| 28 | 28 | } |
@@ -32,14 +32,14 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @return int |
| 34 | 34 | */ |
| 35 | - public function count () { |
|
| 35 | + public function count() { |
|
| 36 | 36 | return count($this->sockets); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * @return SocketInterface[] |
| 41 | 41 | */ |
| 42 | - public function getSockets () { |
|
| 42 | + public function getSockets() { |
|
| 43 | 43 | return $this->sockets; |
| 44 | 44 | } |
| 45 | 45 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * @throws Error |
| 51 | 51 | * @return int Number of sockets that reacted. |
| 52 | 52 | */ |
| 53 | - public function react ($timeout = null) { |
|
| 53 | + public function react($timeout = null) { |
|
| 54 | 54 | /** @var ReactiveInterface[][] $rwe */ |
| 55 | 55 | $rwe = [$this->sockets, [], $this->sockets]; |
| 56 | 56 | $count = AbstractSocket::select($rwe[0], $rwe[1], $rwe[2], $timeout); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @param int $id |
| 70 | 70 | * @return $this |
| 71 | 71 | */ |
| 72 | - public function remove ($id) { |
|
| 72 | + public function remove($id) { |
|
| 73 | 73 | unset($this->sockets[$id]); |
| 74 | 74 | return $this; |
| 75 | 75 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @return static[] Two instances at indices `0` and `1`. |
| 17 | 17 | * @throws Error |
| 18 | 18 | */ |
| 19 | - public static function createUnixPair (...$extra) { |
|
| 19 | + public static function createUnixPair(...$extra) { |
|
| 20 | 20 | if (!@socket_create_pair(AF_UNIX, SOCK_STREAM, 0, $fd)) { |
| 21 | 21 | throw new Error; // reliable errno |
| 22 | 22 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * @return int `SOCK_STREAM` |
| 31 | 31 | */ |
| 32 | - final public static function getType () { |
|
| 32 | + final public static function getType() { |
|
| 33 | 33 | return SOCK_STREAM; |
| 34 | 34 | } |
| 35 | 35 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @return string |
| 44 | 44 | * @throws Error With extra data set to the partially received data. |
| 45 | 45 | */ |
| 46 | - public function read ($length) { |
|
| 46 | + public function read($length) { |
|
| 47 | 47 | $data = ''; |
| 48 | 48 | while ($length > 0) { |
| 49 | 49 | try { |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * @throws Error |
| 74 | 74 | * @return string |
| 75 | 75 | */ |
| 76 | - public function recv ($length, $flags = 0) { |
|
| 76 | + public function recv($length, $flags = 0) { |
|
| 77 | 77 | $count = @socket_recv($this->resource, $data, $length, $flags); |
| 78 | 78 | if ($count === false) { |
| 79 | 79 | $error = new Error($this->resource, SOCKET_EINVAL); |
@@ -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 | } |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @return string |
| 16 | 16 | */ |
| 17 | - public function __toString () { |
|
| 17 | + public function __toString() { |
|
| 18 | 18 | try { |
| 19 | 19 | return implode(':', $this->getPeerName()); |
| 20 | 20 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * @throws Error |
| 39 | 39 | * @return $this |
| 40 | 40 | */ |
| 41 | - public function connect ($address, $port = 0) { |
|
| 41 | + public function connect($address, $port = 0) { |
|
| 42 | 42 | if (!@socket_connect($this->resource, $address, $port)) { |
| 43 | 43 | // ignore expected errors for non-blocking connections |
| 44 | 44 | $errno = Error::getLast($this->resource); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @throws Error |
| 59 | 59 | * @return array Name and port at indices `0` and `1`. |
| 60 | 60 | */ |
| 61 | - public function getPeerName () { |
|
| 61 | + public function getPeerName() { |
|
| 62 | 62 | if ($this->domain === AF_UNIX) { |
| 63 | 63 | return [$this->getOption(self::SO_PEERCRED), 0]; |
| 64 | 64 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * @throws Error |
| 81 | 81 | * @return int Total bytes sent. |
| 82 | 82 | */ |
| 83 | - public function send ($data, $flags = 0) { |
|
| 83 | + public function send($data, $flags = 0) { |
|
| 84 | 84 | $count = @socket_send($this->resource, $data, PHP_INT_MAX, $flags); |
| 85 | 85 | if ($count === false) { |
| 86 | 86 | $error = new Error($this->resource); // reliable errno |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * @throws Error Total bytes sent is set in the extra data. |
| 100 | 100 | * @return $this |
| 101 | 101 | */ |
| 102 | - public function write ($data) { |
|
| 102 | + public function write($data) { |
|
| 103 | 103 | $data = (string)$data; |
| 104 | 104 | $length = strlen($data); |
| 105 | 105 | $total = 0; |
@@ -17,8 +17,7 @@ discard block |
||
| 17 | 17 | public function __toString () { |
| 18 | 18 | try { |
| 19 | 19 | return implode(':', $this->getPeerName()); |
| 20 | - } |
|
| 21 | - catch (\Exception $exception) { |
|
| 20 | + } catch (\Exception $exception) { |
|
| 22 | 21 | return ':'; |
| 23 | 22 | } |
| 24 | 23 | } |
@@ -107,8 +106,7 @@ discard block |
||
| 107 | 106 | try { |
| 108 | 107 | $total += $count = $this->await(self::CH_WRITE)->send($data); |
| 109 | 108 | $data = substr($data, $count); // 0 bytes sent = unaltered buffer |
| 110 | - } |
|
| 111 | - catch (Error $error) { |
|
| 109 | + } catch (Error $error) { |
|
| 112 | 110 | $error->setExtra($total); |
| 113 | 111 | throw $error; |
| 114 | 112 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | /** |
| 11 | 11 | * @return int `SOCK_DGRAM` |
| 12 | 12 | */ |
| 13 | - final public static function getType () { |
|
| 13 | + final public static function getType() { |
|
| 14 | 14 | return SOCK_DGRAM; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * @throws Error |
| 29 | 29 | * @return string |
| 30 | 30 | */ |
| 31 | - public function recv ($length, $flags = 0, &$name = null, &$port = 0) { |
|
| 31 | + public function recv($length, $flags = 0, &$name = null, &$port = 0) { |
|
| 32 | 32 | $count = @socket_recvfrom($this->resource, $data, $length, $flags, $name, $port); |
| 33 | 33 | if ($count === false) { |
| 34 | 34 | $error = new Error($this->resource, SOCKET_EOPNOTSUPP); |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | /** |
| 11 | 11 | * @return int `SOCK_STREAM` |
| 12 | 12 | */ |
| 13 | - final public static function getType () { |
|
| 13 | + final public static function getType() { |
|
| 14 | 14 | return SOCK_STREAM; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @throws Error |
| 26 | 26 | * @return StreamClient The accepted connection, as a client instance. |
| 27 | 27 | */ |
| 28 | - public function accept () { |
|
| 28 | + public function accept() { |
|
| 29 | 29 | if (!$resource = @socket_accept($this->resource)) { |
| 30 | 30 | throw new Error($this->resource); // reliable errno |
| 31 | 31 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @return StreamClient |
| 42 | 42 | * @throws Error |
| 43 | 43 | */ |
| 44 | - protected function createClient ($resource) { |
|
| 44 | + protected function createClient($resource) { |
|
| 45 | 45 | return new StreamClient($resource); |
| 46 | 46 | } |
| 47 | 47 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * @throws Error |
| 56 | 56 | * @return $this |
| 57 | 57 | */ |
| 58 | - public function listen ($backlog = 0) { |
|
| 58 | + public function listen($backlog = 0) { |
|
| 59 | 59 | if (!@socket_listen($this->resource, $backlog)) { |
| 60 | 60 | throw new Error($this->resource); // reliable errno |
| 61 | 61 | } |
@@ -68,6 +68,6 @@ discard block |
||
| 68 | 68 | * @param StreamClient $client |
| 69 | 69 | * @return void |
| 70 | 70 | */ |
| 71 | - protected function onAccept (StreamClient $client) { } |
|
| 71 | + protected function onAccept(StreamClient $client) { } |
|
| 72 | 72 | |
| 73 | 73 | } |
@@ -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) { |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @return static |
| 41 | 41 | * @throws Error |
| 42 | 42 | */ |
| 43 | - public static function create ($domain = AF_INET, ...$extra) { |
|
| 43 | + public static function create($domain = AF_INET, ...$extra) { |
|
| 44 | 44 | if (!$resource = @socket_create($domain, static::getType(), 0)) { // auto-protocol |
| 45 | 45 | throw new Error; // reliable errno |
| 46 | 46 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | /** |
| 51 | 51 | * @return int |
| 52 | 52 | */ |
| 53 | - public static function getType () { |
|
| 53 | + public static function getType() { |
|
| 54 | 54 | return 0; |
| 55 | 55 | } |
| 56 | 56 | |
@@ -66,14 +66,14 @@ discard block |
||
| 66 | 66 | * @return int |
| 67 | 67 | * @throws Error |
| 68 | 68 | */ |
| 69 | - public static function select (array &$read, array &$write, array &$except, $timeout = null) { |
|
| 69 | + public static function select(array &$read, array &$write, array &$except, $timeout = null) { |
|
| 70 | 70 | $getResource = function(SocketInterface $socket) { |
| 71 | 71 | return $socket->getResource(); |
| 72 | 72 | }; |
| 73 | 73 | // PHP 7.1 broke by-reference array_walk_recursive, use array_map instead. |
| 74 | - $r = array_map($getResource,$read); |
|
| 75 | - $w = array_map($getResource,$write); |
|
| 76 | - $e = array_map($getResource,$except); |
|
| 74 | + $r = array_map($getResource, $read); |
|
| 75 | + $w = array_map($getResource, $write); |
|
| 76 | + $e = array_map($getResource, $except); |
|
| 77 | 77 | $usec = (int)(fmod($timeout, 1) * 1000000); // ignored if timeout is null |
| 78 | 78 | $count = @socket_select($r, $w, $e, $timeout, $usec); |
| 79 | 79 | if ($count === false) { |
@@ -96,12 +96,12 @@ discard block |
||
| 96 | 96 | * @throws Error (`SOCKET_EBADFD`) There was a pending error on the socket, including `SO_ERROR`. |
| 97 | 97 | * The existing error code is set in the extra data. |
| 98 | 98 | */ |
| 99 | - public function __construct ($resource) { |
|
| 99 | + public function __construct($resource) { |
|
| 100 | 100 | if (!is_resource($resource) or get_resource_type($resource) !== 'Socket') { |
| 101 | 101 | throw new InvalidArgumentException('Expected an open socket resource.', SOCKET_EBADF); |
| 102 | 102 | } |
| 103 | 103 | elseif (socket_get_option($resource, SOL_SOCKET, SO_TYPE) !== static::getType()) { |
| 104 | - throw new InvalidArgumentException('The given socket resource is of the wrong type for ' . get_class(), SOCKET_ESOCKTNOSUPPORT); |
|
| 104 | + throw new InvalidArgumentException('The given socket resource is of the wrong type for '.get_class(), SOCKET_ESOCKTNOSUPPORT); |
|
| 105 | 105 | } |
| 106 | 106 | elseif ($errno = Error::getLast($resource)) { |
| 107 | 107 | $error = new Error(SOCKET_EBADFD); |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | /** |
| 117 | 117 | * Closes the socket if it's open. |
| 118 | 118 | */ |
| 119 | - public function __destruct () { |
|
| 119 | + public function __destruct() { |
|
| 120 | 120 | $this->close(); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * @return $this |
| 132 | 132 | * @throws Error |
| 133 | 133 | */ |
| 134 | - public function await ($channel) { |
|
| 134 | + public function await($channel) { |
|
| 135 | 135 | $select = [$channel => [$this->resource]]; |
| 136 | 136 | $count = @socket_select($select[self::CH_READ], $select[self::CH_WRITE], $select[self::CH_EXCEPT], null); |
| 137 | 137 | if (!$count) { |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * |
| 152 | 152 | * @return $this |
| 153 | 153 | */ |
| 154 | - public function close () { |
|
| 154 | + public function close() { |
|
| 155 | 155 | // socket_close() never errors, but we guard anyway to prevent |
| 156 | 156 | // a redundant call to onClose(), and an incorrect call to it if |
| 157 | 157 | // the constructor failed and the destructor is calling this. |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | /** |
| 166 | 166 | * @return int |
| 167 | 167 | */ |
| 168 | - final public function getDomain () { |
|
| 168 | + final public function getDomain() { |
|
| 169 | 169 | return $this->domain; |
| 170 | 170 | } |
| 171 | 171 | |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | * |
| 177 | 177 | * @return int |
| 178 | 178 | */ |
| 179 | - final public function getId () { |
|
| 179 | + final public function getId() { |
|
| 180 | 180 | return (int)$this->resource; |
| 181 | 181 | } |
| 182 | 182 | |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | * @throws Error The socket has no such option or is closed. |
| 190 | 190 | * @return mixed The option's value. This is never `false`. |
| 191 | 191 | */ |
| 192 | - public function getOption ($option) { |
|
| 192 | + public function getOption($option) { |
|
| 193 | 193 | $value = @socket_get_option($this->resource, SOL_SOCKET, $option); |
| 194 | 194 | if ($value === false) { |
| 195 | 195 | throw new Error($this->resource, SOCKET_EINVAL); |
@@ -200,14 +200,14 @@ discard block |
||
| 200 | 200 | /** |
| 201 | 201 | * @return int |
| 202 | 202 | */ |
| 203 | - final public function getProtocol () { |
|
| 203 | + final public function getProtocol() { |
|
| 204 | 204 | return $this->protocol; |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
| 208 | 208 | * @return resource |
| 209 | 209 | */ |
| 210 | - final public function getResource () { |
|
| 210 | + final public function getResource() { |
|
| 211 | 211 | return $this->resource; |
| 212 | 212 | } |
| 213 | 213 | |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | * @throws Error |
| 220 | 220 | * @return array String address and integer port at indices `0` and `1`. |
| 221 | 221 | */ |
| 222 | - public function getSockName () { |
|
| 222 | + public function getSockName() { |
|
| 223 | 223 | if (!@socket_getsockname($this->resource, $addr, $port)) { |
| 224 | 224 | throw new Error($this->resource, SOCKET_EOPNOTSUPP); |
| 225 | 225 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * @return bool |
| 235 | 235 | * @throws Error |
| 236 | 236 | */ |
| 237 | - public function isExceptional () { |
|
| 237 | + public function isExceptional() { |
|
| 238 | 238 | return $this->isReady(self::CH_EXCEPT); |
| 239 | 239 | } |
| 240 | 240 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | * |
| 244 | 244 | * @return bool |
| 245 | 245 | */ |
| 246 | - public function isOpen () { |
|
| 246 | + public function isOpen() { |
|
| 247 | 247 | return is_resource($this->resource); |
| 248 | 248 | } |
| 249 | 249 | |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | * @return bool |
| 256 | 256 | * @throws Error |
| 257 | 257 | */ |
| 258 | - public function isReadable () { |
|
| 258 | + public function isReadable() { |
|
| 259 | 259 | return $this->isReady(self::CH_READ); |
| 260 | 260 | } |
| 261 | 261 | |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | * @throws Error |
| 270 | 270 | * @return bool |
| 271 | 271 | */ |
| 272 | - public function isReady ($channel, $timeout = 0.0) { |
|
| 272 | + public function isReady($channel, $timeout = 0.0) { |
|
| 273 | 273 | $usec = (int)(fmod($timeout, 1) * 1000000); // ignored if timeout is null |
| 274 | 274 | $select = [$channel => [$this->resource]]; |
| 275 | 275 | $count = $count = @socket_select($select[self::CH_READ], $select[self::CH_WRITE], $select[self::CH_EXCEPT], $timeout, $usec); |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | * @return bool |
| 288 | 288 | * @throws Error |
| 289 | 289 | */ |
| 290 | - public function isWritable () { |
|
| 290 | + public function isWritable() { |
|
| 291 | 291 | return $this->isReady(self::CH_WRITE, 0); |
| 292 | 292 | } |
| 293 | 293 | |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | * |
| 297 | 297 | * @return void |
| 298 | 298 | */ |
| 299 | - protected function onClose () { } |
|
| 299 | + protected function onClose() { } |
|
| 300 | 300 | |
| 301 | 301 | /** |
| 302 | 302 | * Stub. Called before an I/O channel is shut down. |
@@ -304,14 +304,14 @@ discard block |
||
| 304 | 304 | * @param int $channel |
| 305 | 305 | * @return void |
| 306 | 306 | */ |
| 307 | - protected function onShutdown ($channel) { } |
|
| 307 | + protected function onShutdown($channel) { } |
|
| 308 | 308 | |
| 309 | 309 | /** |
| 310 | 310 | * Stub. Called when an I/O timeout has occurred, before it is thrown. |
| 311 | 311 | * |
| 312 | 312 | * @return void |
| 313 | 313 | */ |
| 314 | - protected function onTimeout () { } |
|
| 314 | + protected function onTimeout() { } |
|
| 315 | 315 | |
| 316 | 316 | /** |
| 317 | 317 | * Enables or disables blocking. |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | * @throws Error |
| 332 | 332 | * @return $this |
| 333 | 333 | */ |
| 334 | - public function setBlocking ($blocking) { |
|
| 334 | + public function setBlocking($blocking) { |
|
| 335 | 335 | if ($blocking) { |
| 336 | 336 | $success = @socket_set_block($this->resource); |
| 337 | 337 | } |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | * @throws Error |
| 355 | 355 | * @return $this |
| 356 | 356 | */ |
| 357 | - public function setOption ($option, $value) { |
|
| 357 | + public function setOption($option, $value) { |
|
| 358 | 358 | if (!@socket_set_option($this->resource, SOL_SOCKET, $option, $value)) { |
| 359 | 359 | throw new Error($this->resource, SOCKET_EINVAL); |
| 360 | 360 | } |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | * @throws Error |
| 369 | 369 | * @return $this |
| 370 | 370 | */ |
| 371 | - public function setTimeout ($timeout) { |
|
| 371 | + public function setTimeout($timeout) { |
|
| 372 | 372 | $timeval = ['sec' => (int)$timeout, 'usec' => (int)(fmod($timeout, 1) * 1000000)]; |
| 373 | 373 | $this->setOption(SO_RCVTIMEO, $timeval); |
| 374 | 374 | $this->setOption(SO_SNDTIMEO, $timeval); |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | * @throws Error |
| 396 | 396 | * @return $this |
| 397 | 397 | */ |
| 398 | - public function shutdown ($channel) { |
|
| 398 | + public function shutdown($channel) { |
|
| 399 | 399 | $this->onShutdown($channel); |
| 400 | 400 | if (!@socket_shutdown($this->resource, $channel)) { |
| 401 | 401 | throw new Error($this->resource); // reliable errno |
@@ -42,40 +42,40 @@ |
||
| 42 | 42 | * |
| 43 | 43 | * @return int `AF_*` |
| 44 | 44 | */ |
| 45 | - public function getDomain (); |
|
| 45 | + public function getDomain(); |
|
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * Returns the underlying socket resource as an integer. |
| 49 | 49 | * |
| 50 | 50 | * @return int |
| 51 | 51 | */ |
| 52 | - public function getId (); |
|
| 52 | + public function getId(); |
|
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * Returns the protocol constant used by the socket. |
| 56 | 56 | * |
| 57 | 57 | * @return int |
| 58 | 58 | */ |
| 59 | - public function getProtocol (); |
|
| 59 | + public function getProtocol(); |
|
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * Returns the underlying socket resource. |
| 63 | 63 | * |
| 64 | 64 | * @return resource |
| 65 | 65 | */ |
| 66 | - public function getResource (); |
|
| 66 | + public function getResource(); |
|
| 67 | 67 | |
| 68 | 68 | /** |
| 69 | 69 | * Returns the socket type constant for the class. |
| 70 | 70 | * |
| 71 | 71 | * @return int `SOCK_*` |
| 72 | 72 | */ |
| 73 | - public static function getType (); |
|
| 73 | + public static function getType(); |
|
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | 76 | * Whether the underlying resource is open. |
| 77 | 77 | * |
| 78 | 78 | * @return bool |
| 79 | 79 | */ |
| 80 | - public function isOpen (); |
|
| 80 | + public function isOpen(); |
|
| 81 | 81 | } |
| 82 | 82 | \ No newline at end of file |