@@ -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 | } |
@@ -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); |
@@ -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; |
@@ -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 | } |
@@ -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 |
@@ -14,13 +14,13 @@ |
||
| 14 | 14 | * |
| 15 | 15 | * @return void |
| 16 | 16 | */ |
| 17 | - public function onExceptional (); |
|
| 17 | + public function onExceptional(); |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Called when the socket has readable data. |
| 21 | 21 | * |
| 22 | 22 | * @return void |
| 23 | 23 | */ |
| 24 | - public function onReadable (); |
|
| 24 | + public function onReadable(); |
|
| 25 | 25 | |
| 26 | 26 | } |
| 27 | 27 | \ No newline at end of file |