@@ -12,7 +12,7 @@ |
||
12 | 12 | * |
13 | 13 | * @return int |
14 | 14 | */ |
15 | - final public static function getType (): int { |
|
15 | + final public static function getType(): int { |
|
16 | 16 | return SOCK_DGRAM; |
17 | 17 | } |
18 | 18 |
@@ -14,13 +14,13 @@ |
||
14 | 14 | * |
15 | 15 | * @return void |
16 | 16 | */ |
17 | - public function onOutOfBand (): void; |
|
17 | + public function onOutOfBand(): void; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Called by the reactor when the socket has readable data. |
21 | 21 | * |
22 | 22 | * @return void |
23 | 23 | */ |
24 | - public function onReadable (): void; |
|
24 | + public function onReadable(): void; |
|
25 | 25 | |
26 | 26 | } |
27 | 27 | \ No newline at end of file |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | protected $frame; |
27 | 27 | |
28 | - public function __construct (int $code, string $message = '', Frame $frame = null, Throwable $previous = null) { |
|
28 | + public function __construct(int $code, string $message = '', Frame $frame = null, Throwable $previous = null) { |
|
29 | 29 | parent::__construct($message, $code, $previous); |
30 | 30 | $this->frame = $frame; |
31 | 31 | } |
@@ -33,14 +33,14 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * @return mixed |
35 | 35 | */ |
36 | - public function getExtra () { |
|
36 | + public function getExtra() { |
|
37 | 37 | return $this->extra; |
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
41 | 41 | * @return Frame|null |
42 | 42 | */ |
43 | - public function getFrame () { |
|
43 | + public function getFrame() { |
|
44 | 44 | return $this->frame; |
45 | 45 | } |
46 | 46 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param mixed $extra |
49 | 49 | * @return $this |
50 | 50 | */ |
51 | - public function setExtra ($extra) { |
|
51 | + public function setExtra($extra) { |
|
52 | 52 | $this->extra = $extra; |
53 | 53 | return $this; |
54 | 54 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return string |
20 | 20 | */ |
21 | - public function __toString () { |
|
21 | + public function __toString() { |
|
22 | 22 | try { |
23 | 23 | return implode(':', $this->getPeerName()); |
24 | 24 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @return $this |
42 | 42 | * @throws SocketError |
43 | 43 | */ |
44 | - public function connect (string $address, int $port = 0) { |
|
44 | + public function connect(string $address, int $port = 0) { |
|
45 | 45 | if (!@socket_connect($this->resource, $address, $port)) { |
46 | 46 | // ignore expected errors for non-blocking connections |
47 | 47 | $errno = SocketError::getLast($this->resource); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @return array `[ 0 => address, 1 => port ]` |
62 | 62 | * @throws SocketError |
63 | 63 | */ |
64 | - public function getPeerName (): array { |
|
64 | + public function getPeerName(): array { |
|
65 | 65 | if ($this->getDomain() === AF_UNIX) { |
66 | 66 | return [$this->getOption(17), 0]; // SO_PEERCRED is not exposed by PHP |
67 | 67 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @return int Total bytes sent. |
82 | 82 | * @throws SocketError |
83 | 83 | */ |
84 | - public function send (string $data, int $flags = 0): int { |
|
84 | + public function send(string $data, int $flags = 0): int { |
|
85 | 85 | $count = @socket_send($this->resource, $data, strlen($data), $flags); |
86 | 86 | if ($count === false) { |
87 | 87 | throw new SocketError($this->resource); // reliable errno |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @return $this |
97 | 97 | * @throws SocketError `int` total bytes sent is set as the extra data. |
98 | 98 | */ |
99 | - public function write (string $data) { |
|
99 | + public function write(string $data) { |
|
100 | 100 | $length = strlen($data); |
101 | 101 | $total = 0; |
102 | 102 | while ($total < $length) { |
@@ -27,20 +27,20 @@ |
||
27 | 27 | * |
28 | 28 | * @return int |
29 | 29 | */ |
30 | - public function getId (): int; |
|
30 | + public function getId(): int; |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * Returns the underlying socket resource. |
34 | 34 | * |
35 | 35 | * @return resource |
36 | 36 | */ |
37 | - public function getResource (); |
|
37 | + public function getResource(); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Whether the underlying resource is usable. |
41 | 41 | * |
42 | 42 | * @return bool |
43 | 43 | */ |
44 | - public function isOpen (): bool; |
|
44 | + public function isOpen(): bool; |
|
45 | 45 | |
46 | 46 | } |
47 | 47 | \ No newline at end of file |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param resource $resource PHP socket resource, or `null` for the global error. |
30 | 30 | * @return int If the resource is closed or not a socket, `SOCKET_EBADF` is returned. |
31 | 31 | */ |
32 | - public static function getLast ($resource = null) { |
|
32 | + public static function getLast($resource = null) { |
|
33 | 33 | if (isset($resource)) { |
34 | 34 | if (@get_resource_type($resource) !== 'Socket') { |
35 | 35 | return SOCKET_EBADF; // Bad file descriptor |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @param int $fallback Code to assume if one can't be found via the subject. |
63 | 63 | * @param SocketError|null $previous Slippage of a prior error. |
64 | 64 | */ |
65 | - public function __construct ($subject = null, $fallback = 0, SocketError $previous = null) { |
|
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 | 68 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | /** |
78 | 78 | * @return mixed |
79 | 79 | */ |
80 | - public function getExtra () { |
|
80 | + public function getExtra() { |
|
81 | 81 | return $this->extra; |
82 | 82 | } |
83 | 83 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @param mixed $extra |
86 | 86 | * @return $this |
87 | 87 | */ |
88 | - public function setExtra ($extra) { |
|
88 | + public function setExtra($extra) { |
|
89 | 89 | $this->extra = $extra; |
90 | 90 | return $this; |
91 | 91 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return string |
20 | 20 | */ |
21 | - public function __toString () { |
|
21 | + public function __toString() { |
|
22 | 22 | try { |
23 | 23 | return implode(':', $this->getSockName()); |
24 | 24 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @return $this |
41 | 41 | * @throws SocketError |
42 | 42 | */ |
43 | - public function bind (string $address, int $port = 0) { |
|
43 | + public function bind(string $address, int $port = 0) { |
|
44 | 44 | if (!@socket_bind($this->resource, $address, $port)) { |
45 | 45 | throw new SocketError($this->resource, SOCKET_EOPNOTSUPP); |
46 | 46 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * |
13 | 13 | * @return int |
14 | 14 | */ |
15 | - final public static function getType (): int { |
|
15 | + final public static function getType(): int { |
|
16 | 16 | return SOCK_STREAM; |
17 | 17 | } |
18 | 18 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @return static[] Two instances at indices `0` and `1`. |
26 | 26 | * @throws SocketError |
27 | 27 | */ |
28 | - public static function newUnixPair (...$extra) { |
|
28 | + public static function newUnixPair(...$extra) { |
|
29 | 29 | if (!@socket_create_pair(AF_UNIX, SOCK_STREAM, 0, $fd)) { |
30 | 30 | throw new SocketError; // reliable errno |
31 | 31 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @return string |
45 | 45 | * @throws SocketError The partially read data is attached. |
46 | 46 | */ |
47 | - public function read (int $length): string { |
|
47 | + public function read(int $length): string { |
|
48 | 48 | try { |
49 | 49 | $data = ''; |
50 | 50 | do { |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | * @return string |
72 | 72 | * @throws SocketError |
73 | 73 | */ |
74 | - public function recv (int $maxLength, int $flags = 0): string { |
|
74 | + public function recv(int $maxLength, int $flags = 0): string { |
|
75 | 75 | if (false === @socket_recv($this->resource, $data, $maxLength, $flags)) { |
76 | 76 | throw new SocketError($this->resource, SOCKET_EINVAL); |
77 | 77 | } |
78 | - return (string)$data; // cast needed, will be null if 0 bytes are read. |
|
78 | + return (string) $data; // cast needed, will be null if 0 bytes are read. |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @return string |
86 | 86 | * @throws SocketError |
87 | 87 | */ |
88 | - public function recvAll (int $flags = 0): string { |
|
88 | + public function recvAll(int $flags = 0): string { |
|
89 | 89 | $flags = ($flags & ~MSG_WAITALL) | MSG_DONTWAIT; |
90 | 90 | $length = $this->getOption(SO_RCVBUF); |
91 | 91 | try { |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * |
13 | 13 | * @return int |
14 | 14 | */ |
15 | - final public static function getType (): int { |
|
15 | + final public static function getType(): int { |
|
16 | 16 | return SOCK_DGRAM; |
17 | 17 | } |
18 | 18 | |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | * @return string |
29 | 29 | * @throws SocketError |
30 | 30 | */ |
31 | - public function recv (int $length, int $flags = 0, string &$name = '', int &$port = 0): string { |
|
31 | + public function recv(int $length, int $flags = 0, string &$name = '', int &$port = 0): string { |
|
32 | 32 | $count = @socket_recvfrom($this->resource, $data, $length, $flags, $name, $port); |
33 | 33 | if ($count === false) { |
34 | 34 | throw new SocketError($this->resource, SOCKET_EOPNOTSUPP); |
35 | 35 | } |
36 | - return (string)$data; // cast needed, will be null if 0 bytes are read |
|
36 | + return (string) $data; // cast needed, will be null if 0 bytes are read |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | } |
40 | 40 | \ No newline at end of file |