Passed
Push — master ( b4e552...a91d54 )
by y
03:05
created
src/StreamClient.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
      * @return static[] Two instances at indices `0` and `1`.
18 18
      * @throws Error
19 19
      */
20
-    public static function newUnixPair (...$extra) {
20
+    public static function newUnixPair(...$extra) {
21 21
         if (!@socket_create_pair(AF_UNIX, SOCK_STREAM, 0, $fd)) {
22 22
             throw new Error; // reliable errno
23 23
         }
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      *
33 33
      * @return int
34 34
      */
35
-    final public static function getType () {
35
+    final public static function getType() {
36 36
         return SOCK_STREAM;
37 37
     }
38 38
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      * @return string
47 47
      * @throws Error The error's extra data is set to what was partially read.
48 48
      */
49
-    public function read ($length) {
49
+    public function read($length) {
50 50
         $data = '';
51 51
         while ($length > 0) {
52 52
             try {
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      * @throws Error
77 77
      * @return string
78 78
      */
79
-    public function recv ($length, $flags = 0) {
79
+    public function recv($length, $flags = 0) {
80 80
         $count = @socket_recv($this->resource, $data, $length, $flags);
81 81
         if ($count === false) {
82 82
             $error = new Error($this->resource, SOCKET_EINVAL);
Please login to merge, or discard this patch.
src/WebSocketClient.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
      * @param $resource
19 19
      * @param WebSocketServer $server
20 20
      */
21
-    public function __construct ($resource, WebSocketServer $server) {
21
+    public function __construct($resource, WebSocketServer $server) {
22 22
         parent::__construct($resource);
23 23
         $this->server = $server;
24 24
     }
@@ -26,33 +26,33 @@  discard block
 block discarded – undo
26 26
     /**
27 27
      * Removes the client from the server and reactor.
28 28
      */
29
-    protected function onClose () {
29
+    protected function onClose() {
30 30
         $this->server->remove($this);
31 31
     }
32 32
 
33 33
     /**
34 34
      * @param string $payload
35 35
      */
36
-    protected function onData (string $payload): void {
36
+    protected function onData(string $payload): void {
37 37
     }
38 38
 
39 39
     /**
40 40
      * WebSockets do not use the out-of-band channel.
41 41
      */
42
-    final public function onOutOfBand () {
42
+    final public function onOutOfBand() {
43 43
     }
44 44
 
45 45
     /**
46 46
      * When a browser responds to a ping.
47 47
      */
48
-    protected function onPong (): void {
48
+    protected function onPong(): void {
49 49
         // stub
50 50
     }
51 51
 
52 52
     /**
53 53
      * Reads framed messages.
54 54
      */
55
-    public function onReadable (): void {
55
+    public function onReadable(): void {
56 56
         $data = $this->recv(4096);
57 57
         $frame = new WebSocketFrame($data);
58 58
         if ($frame->isText()) {
@@ -74,17 +74,17 @@  discard block
 block discarded – undo
74 74
      *
75 75
      * @param string $text
76 76
      */
77
-    protected function onText (string $text): void {
77
+    protected function onText(string $text): void {
78 78
     }
79 79
 
80 80
     /**
81 81
      * Pings the browser.
82 82
      */
83
-    public function ping () {
83
+    public function ping() {
84 84
         $this->write(WebSocketFrame::pack('', WebSocketFrame::OP_PING));
85 85
     }
86 86
 
87
-    public function writeText (string $message) {
87
+    public function writeText(string $message) {
88 88
         $packed = WebSocketFrame::pack($message);
89 89
         $this->write($packed);
90 90
     }
Please login to merge, or discard this patch.
src/StreamServer.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
      *
13 13
      * @return int
14 14
      */
15
-    final public static function getType () {
15
+    final public static function getType() {
16 16
         return SOCK_STREAM;
17 17
     }
18 18
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
      * @throws Error
28 28
      * @return StreamClient The accepted connection, as a client instance.
29 29
      */
30
-    public function accept () {
30
+    public function accept() {
31 31
         if (!$resource = @socket_accept($this->resource)) {
32 32
             throw new Error($this->resource); // reliable errno
33 33
         }
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      * @throws Error
47 47
      * @return $this
48 48
      */
49
-    public function listen ($backlog = 0) {
49
+    public function listen($backlog = 0) {
50 50
         if (!@socket_listen($this->resource, $backlog)) {
51 51
             throw new Error($this->resource); // reliable errno
52 52
         }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      * @return StreamClient
61 61
      * @throws Error
62 62
      */
63
-    protected function newClient ($resource) {
63
+    protected function newClient($resource) {
64 64
         return new StreamClient($resource);
65 65
     }
66 66
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      * @param StreamClient $client
71 71
      * @return void
72 72
      */
73
-    protected function onAccept (StreamClient $client) {
73
+    protected function onAccept(StreamClient $client) {
74 74
     }
75 75
 
76 76
 }
Please login to merge, or discard this patch.
src/AbstractSocket.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      * @return static
42 42
      * @throws Error
43 43
      */
44
-    public static function create ($domain = AF_INET, ...$extra) {
44
+    public static function create($domain = AF_INET, ...$extra) {
45 45
         if (!$resource = @socket_create($domain, static::getType(), 0)) { // auto-protocol
46 46
             throw new Error; // reliable errno
47 47
         }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      * @return int
61 61
      * @throws Error
62 62
      */
63
-    public static function select (array &$read, array &$write, array &$except, $timeout = null) {
63
+    public static function select(array &$read, array &$write, array &$except, $timeout = null) {
64 64
         $getResource = function(SocketInterface $socket) {
65 65
             return $socket->getResource();
66 66
         };
@@ -90,12 +90,12 @@  discard block
 block discarded – undo
90 90
      * @throws Error (`SOCKET_EBADFD`) There was a pending error on the socket.
91 91
      * The preexisting error code is set as the exception's extra data.
92 92
      */
93
-    public function __construct ($resource) {
93
+    public function __construct($resource) {
94 94
         if (!is_resource($resource) or get_resource_type($resource) !== 'Socket') {
95 95
             throw new InvalidArgumentException('Expected an open socket resource.', SOCKET_EBADF);
96 96
         }
97 97
         elseif (socket_get_option($resource, SOL_SOCKET, SO_TYPE) !== static::getType()) {
98
-            throw new InvalidArgumentException('The given socket resource is of the wrong type for ' . get_class(), SOCKET_ESOCKTNOSUPPORT);
98
+            throw new InvalidArgumentException('The given socket resource is of the wrong type for '.get_class(), SOCKET_ESOCKTNOSUPPORT);
99 99
         }
100 100
         elseif ($errno = Error::getLast($resource)) {
101 101
             $error = new Error(SOCKET_EBADFD);
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
     /**
111 111
      * Closes the socket if it's open.
112 112
      */
113
-    public function __destruct () {
113
+    public function __destruct() {
114 114
         $this->close();
115 115
     }
116 116
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
      * @return $this
126 126
      * @throws Error
127 127
      */
128
-    public function await ($channel) {
128
+    public function await($channel) {
129 129
         $select = [$channel => [$this->resource]];
130 130
         $count = @socket_select($select[self::CH_READ], $select[self::CH_WRITE], $select[self::CH_EXCEPT], null);
131 131
         if (!$count) {
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      *
145 145
      * @return $this
146 146
      */
147
-    public function close () {
147
+    public function close() {
148 148
         // socket_close() never errors, but we guard anyway to prevent
149 149
         // a redundant call to onClose(), and an incorrect call to it if
150 150
         // the constructor failed and the destructor is calling this.
@@ -158,14 +158,14 @@  discard block
 block discarded – undo
158 158
     /**
159 159
      * @return int
160 160
      */
161
-    final public function getDomain () {
161
+    final public function getDomain() {
162 162
         return $this->domain;
163 163
     }
164 164
 
165 165
     /**
166 166
      * @return int
167 167
      */
168
-    final public function getId () {
168
+    final public function getId() {
169 169
         return (int)$this->resource;
170 170
     }
171 171
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
      * @throws Error
179 179
      * @return mixed The option's value. This is never `false`.
180 180
      */
181
-    public function getOption ($option) {
181
+    public function getOption($option) {
182 182
         $value = @socket_get_option($this->resource, SOL_SOCKET, $option);
183 183
         if ($value === false) {
184 184
             throw new Error($this->resource, SOCKET_EINVAL);
@@ -189,14 +189,14 @@  discard block
 block discarded – undo
189 189
     /**
190 190
      * @return int
191 191
      */
192
-    final public function getProtocol () {
192
+    final public function getProtocol() {
193 193
         return $this->protocol;
194 194
     }
195 195
 
196 196
     /**
197 197
      * @return resource
198 198
      */
199
-    final public function getResource () {
199
+    final public function getResource() {
200 200
         return $this->resource;
201 201
     }
202 202
 
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
      * @throws Error
209 209
      * @return array String address/file and integer port at indices `0` and `1`.
210 210
      */
211
-    public function getSockName () {
211
+    public function getSockName() {
212 212
         if (!@socket_getsockname($this->resource, $addr, $port)) {
213 213
             throw new Error($this->resource, SOCKET_EOPNOTSUPP);
214 214
         }
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
      *
221 221
      * @return bool
222 222
      */
223
-    public function isOpen () {
223
+    public function isOpen() {
224 224
         return is_resource($this->resource);
225 225
     }
226 226
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
      * @return bool
233 233
      * @throws Error
234 234
      */
235
-    public function isOutOfBand () {
235
+    public function isOutOfBand() {
236 236
         return $this->isReady(self::CH_EXCEPT);
237 237
     }
238 238
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
      * @return bool
245 245
      * @throws Error
246 246
      */
247
-    final public function isReadable () {
247
+    final public function isReadable() {
248 248
         return $this->isReady(self::CH_READ);
249 249
     }
250 250
 
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
      * @return bool
259 259
      * @throws Error
260 260
      */
261
-    public function isReady ($channel, $timeout = 0.0) {
261
+    public function isReady($channel, $timeout = 0.0) {
262 262
         $usec = (int)(fmod($timeout, 1) * 1000000); // ignored if timeout is null
263 263
         $select = [$channel => [$this->resource]];
264 264
         $count = $count = @socket_select(
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
      * @return bool
283 283
      * @throws Error
284 284
      */
285
-    final public function isWritable () {
285
+    final public function isWritable() {
286 286
         return $this->isReady(self::CH_WRITE);
287 287
     }
288 288
 
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
      *
292 292
      * @return void
293 293
      */
294
-    protected function onClose () {
294
+    protected function onClose() {
295 295
     }
296 296
 
297 297
     /**
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
      * @param int $channel `SocketInterface` channel constant.
301 301
      * @return void
302 302
      */
303
-    protected function onShutdown ($channel) {
303
+    protected function onShutdown($channel) {
304 304
     }
305 305
 
306 306
     /**
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
      *
309 309
      * @return void
310 310
      */
311
-    protected function onTimeout () {
311
+    protected function onTimeout() {
312 312
     }
313 313
 
314 314
     /**
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
      * @throws Error
330 330
      * @return $this
331 331
      */
332
-    public function setBlocking ($blocking) {
332
+    public function setBlocking($blocking) {
333 333
         if ($blocking) {
334 334
             $success = @socket_set_block($this->resource);
335 335
         }
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
      * @throws Error
353 353
      * @return $this
354 354
      */
355
-    public function setOption ($option, $value) {
355
+    public function setOption($option, $value) {
356 356
         if (!@socket_set_option($this->resource, SOL_SOCKET, $option, $value)) {
357 357
             throw new Error($this->resource, SOCKET_EINVAL);
358 358
         }
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
      * @return $this
367 367
      * @throws Error
368 368
      */
369
-    public function setTimeout ($timeout) {
369
+    public function setTimeout($timeout) {
370 370
         $timeval = ['sec' => (int)$timeout, 'usec' => (int)(fmod($timeout, 1) * 1000000)];
371 371
         $this->setOption(SO_RCVTIMEO, $timeval);
372 372
         $this->setOption(SO_SNDTIMEO, $timeval);
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
      * @throws Error
394 394
      * @return $this
395 395
      */
396
-    public function shutdown ($channel) {
396
+    public function shutdown($channel) {
397 397
         $this->onShutdown($channel);
398 398
         if (!@socket_shutdown($this->resource, $channel)) {
399 399
             throw new Error($this->resource); // reliable errno
Please login to merge, or discard this patch.