Completed
Push — master ( bf368b...88d0e2 )
by Arthur
01:43
created
src/Contracts/WebSocketServerContract.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,10 +21,10 @@
 block discarded – undo
21 21
     const HEADER_HTTP1_1                   = 'HTTP/1.1 101 Web Socket Protocol Handshake';
22 22
     const HEADER_WEBSOCKET_ACCEPT_HASH     = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11';
23 23
     const HEADERS_UPGRADE_KEY              = 'Upgrade',
24
-          HEADERS_CONNECTION_KEY           = 'Connection',
25
-          HEADERS_SEC_WEBSOCKET_ACCEPT_KEY = 'Sec-WebSocket-Accept';
24
+            HEADERS_CONNECTION_KEY           = 'Connection',
25
+            HEADERS_SEC_WEBSOCKET_ACCEPT_KEY = 'Sec-WebSocket-Accept';
26 26
     const HEADERS_UPGRADE_VALUE            = 'websocket',
27
-          HEADERS_CONNECTION_VALUE         = 'Upgrade';
27
+            HEADERS_CONNECTION_VALUE         = 'Upgrade';
28 28
     const HEADERS_EOL                      = "\r\n";
29 29
     const SEC_WEBSOCKET_KEY_PTRN           = '/Sec-WebSocket-Key:\s(.*)\n/';
30 30
 
Please login to merge, or discard this patch.
src/Components/WscMain.php 2 patches
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
     }
147 147
 
148 148
     /**
149
-     * @return mixed|resource
149
+     * @return resource|null
150 150
      * @throws \InvalidArgumentException
151 151
      */
152 152
     private function getStreamContext()
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
     /**
246 246
      * Sends message to opened socket connection client->server
247 247
      *
248
-     * @param $payload
248
+     * @param string $payload
249 249
      * @param string $opcode
250 250
      * @throws \InvalidArgumentException
251 251
      * @throws BadOpcodeException
@@ -285,10 +285,10 @@  discard block
 block discarded – undo
285 285
     }
286 286
 
287 287
     /**
288
-     * @param $final
289
-     * @param $payload
290
-     * @param $opcode
291
-     * @param $masked
288
+     * @param boolean $final
289
+     * @param string $payload
290
+     * @param string $opcode
291
+     * @param boolean $masked
292 292
      * @throws ConnectionException
293 293
      * @throws \Exception
294 294
      */
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
      *
496 496
      * @param integer $status http://tools.ietf.org/html/rfc6455#section-7.4
497 497
      * @param string $message A closing message, max 125 bytes.
498
-     * @return bool|null|string
498
+     * @return null|string
499 499
      * @throws BadOpcodeException
500 500
      */
501 501
     public function close(int $status = 1000, string $message = 'ttfn')
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
         return 'GET ' . $pathWithQuery . " HTTP/1.1\r\n"
196 196
             . implode(
197 197
                 "\r\n", array_map(
198
-                    function ($key, $value) {
198
+                    function($key, $value) {
199 199
                         return "$key: $value";
200 200
                     }, array_keys($headers), $headers
201 201
                 )
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
         // Binary string for header.
298 298
         $frameHeadBin = '';
299 299
         // Write FIN, final fragment bit.
300
-        $frameHeadBin .= (bool)$final ? '1' : '0';
300
+        $frameHeadBin .= (bool) $final ? '1' : '0';
301 301
         // RSV 1, 2, & 3 false and unused.
302 302
         $frameHeadBin .= '000';
303 303
         // Opcode rest of the byte.
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 
382 382
         // Is this the final fragment?  // Bit 0 in byte 0
383 383
         /// @todo Handle huge payloads with multiple fragments.
384
-        $final = (bool)(ord($data[0]) & 1 << 7);
384
+        $final = (bool) (ord($data[0]) & 1 << 7);
385 385
 
386 386
         // Parse opcode
387 387
         $opcode_int = ord($data[0]) & 31; // Bits 4-7
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
     private function getPayloadData(string $data, int $payloadLength): string
445 445
     {
446 446
         // Masking?
447
-        $mask = (bool)(ord($data[1]) >> 7);  // Bit 0 in byte 1
447
+        $mask = (bool) (ord($data[1]) >> 7); // Bit 0 in byte 1
448 448
         $payload = '';
449 449
         $maskingKey = '';
450 450
 
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
      */
478 478
     private function getPayloadLength(string $data)
479 479
     {
480
-        $payloadLength = (int)ord($data[1]) & self::MASK_127; // Bits 1-7 in byte 1
480
+        $payloadLength = (int) ord($data[1]) & self::MASK_127; // Bits 1-7 in byte 1
481 481
         if ($payloadLength > self::MASK_125) {
482 482
             if ($payloadLength === self::MASK_126) {
483 483
                 $data = $this->read(2); // 126: Payload is a 16-bit unsigned int
Please login to merge, or discard this patch.
src/WebSocketServer.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@
 block discarded – undo
68 68
         $server = stream_socket_server("tcp://{$this->config->getHost()}:{$this->config->getPort()}", $errno, $errorMessage);
69 69
 
70 70
         if ($server === false) {
71
-           throw new WebSocketException('Could not bind to socket: ' . $errno . ' - ' . $errorMessage . PHP_EOL);
71
+            throw new WebSocketException('Could not bind to socket: ' . $errno . ' - ' . $errorMessage . PHP_EOL);
72 72
         }
73 73
 
74 74
         @cli_set_process_title(self::PROC_TITLE);
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -327,7 +327,7 @@
 block discarded – undo
327 327
         }
328 328
 
329 329
         $key = $match[1];
330
-        $this->handshakes[(int)$client] = $key;
330
+        $this->handshakes[(int) $client] = $key;
331 331
 
332 332
         // sending header according to WebSocket Protocol
333 333
         $secWebSocketAccept = base64_encode(sha1(trim($key) . self::HEADER_WEBSOCKET_ACCEPT_HASH, true));
Please login to merge, or discard this patch.
src/Components/Connection.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -139,7 +139,7 @@
 block discarded – undo
139 139
      */
140 140
     public function getUniqueSocketId(): int
141 141
     {
142
-        return (int)$this->socketConnection;
142
+        return (int) $this->socketConnection;
143 143
     }
144 144
 
145 145
     /**
Please login to merge, or discard this patch.