Completed
Branch master (2d58e0)
by Arthur
01:43
created
src/WebSocketServer.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -285,14 +285,14 @@
 block discarded – undo
285 285
     private function handshake($client, $headers)
286 286
     {
287 287
         $match = [];
288
-        $key = empty($this->handshakes[(int)$client]) ? 0 : $this->handshakes[(int)$client];
288
+        $key = empty($this->handshakes[(int) $client]) ? 0 : $this->handshakes[(int) $client];
289 289
         preg_match(self::SEC_WEBSOCKET_KEY_PTRN, $headers, $match);
290 290
         if (empty($match[1])) {
291 291
             return false;
292 292
         }
293 293
 
294 294
         $key = $match[1];
295
-        $this->handshakes[(int)$client] = $key;
295
+        $this->handshakes[(int) $client] = $key;
296 296
 
297 297
         // sending header according to WebSocket Protocol
298 298
         $secWebSocketAccept = base64_encode(sha1(trim($key) . self::HEADER_WEBSOCKET_ACCEPT_HASH, true));
Please login to merge, or discard this patch.
src/Components/WscMain.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         $header = 'GET ' . $path_with_query . " HTTP/1.1\r\n"
103 103
             . implode(
104 104
                 "\r\n", array_map(
105
-                    function ($key, $value) {
105
+                    function($key, $value) {
106 106
                         return "$key: $value";
107 107
                     }, array_keys($headers), $headers
108 108
                 )
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         // Binary string for header.
205 205
         $frameHeadBin = '';
206 206
         // Write FIN, final fragment bit.
207
-        $frameHeadBin .= (bool)$final ? '1' : '0';
207
+        $frameHeadBin .= (bool) $final ? '1' : '0';
208 208
         // RSV 1, 2, & 3 false and unused.
209 209
         $frameHeadBin .= '000';
210 210
         // Opcode rest of the byte.
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 
270 270
         // Is this the final fragment?  // Bit 0 in byte 0
271 271
         /// @todo Handle huge payloads with multiple fragments.
272
-        $final = (boolean)(ord($data[0]) & 1 << 7);
272
+        $final = (boolean) (ord($data[0]) & 1 << 7);
273 273
 
274 274
         // Should be unused, and must be false…  // Bits 1, 2, & 3
275 275
         //      $rsv1  = (boolean) (ord($data[0]) & 1 << 6);
@@ -289,12 +289,12 @@  discard block
 block discarded – undo
289 289
         }
290 290
 
291 291
         // Masking?
292
-        $mask = (boolean)(ord($data[1]) >> 7);  // Bit 0 in byte 1
292
+        $mask = (boolean) (ord($data[1]) >> 7); // Bit 0 in byte 1
293 293
 
294 294
         $payload = '';
295 295
 
296 296
         // Payload length
297
-        $payload_length = (integer)ord($data[1]) & self::MASK_127; // Bits 1-7 in byte 1
297
+        $payload_length = (integer) ord($data[1]) & self::MASK_127; // Bits 1-7 in byte 1
298 298
         if ($payload_length > self::MASK_125) {
299 299
             if ($payload_length === self::MASK_126) {
300 300
                 $data = $this->read(2); // 126: Payload is a 16-bit unsigned int
Please login to merge, or discard this patch.
Doc Comments   +13 added lines patch added patch discarded remove patch
@@ -167,6 +167,9 @@  discard block
 block discarded – undo
167 167
         return $this->options['fragment_size'];
168 168
     }
169 169
 
170
+    /**
171
+     * @param string $payload
172
+     */
170 173
     public function send($payload, $opcode = 'text', $masked = true)
171 174
     {
172 175
         if (!$this->is_connected) {
@@ -199,6 +202,12 @@  discard block
 block discarded – undo
199 202
         }
200 203
     }
201 204
 
205
+    /**
206
+     * @param boolean $final
207
+     * @param string $payload
208
+     * @param string $opcode
209
+     * @param boolean $masked
210
+     */
202 211
     protected function send_fragment($final, $payload, $opcode, $masked)
203 212
     {
204 213
         // Binary string for header.
@@ -375,6 +384,9 @@  discard block
 block discarded – undo
375 384
         return $this->receive(); // Receiving a close frame will close the socket now.
376 385
     }
377 386
 
387
+    /**
388
+     * @param string $data
389
+     */
378 390
     protected function write($data)
379 391
     {
380 392
         $written = fwrite($this->socket, $data);
@@ -412,6 +424,7 @@  discard block
 block discarded – undo
412 424
 
413 425
     /**
414 426
      * Helper to convert a binary to a string of '0' and '1'.
427
+     * @param string $string
415 428
      */
416 429
     protected static function sprintB($string)
417 430
     {
Please login to merge, or discard this patch.