@@ -184,6 +184,9 @@ discard block |
||
| 184 | 184 | return $this->options['fragment_size']; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | + /** |
|
| 188 | + * @param string $payload |
|
| 189 | + */ |
|
| 187 | 190 | public function send($payload, $opcode = 'text', $masked = true) |
| 188 | 191 | { |
| 189 | 192 | if (!$this->isConnected) { |
@@ -217,10 +220,10 @@ discard block |
||
| 217 | 220 | } |
| 218 | 221 | |
| 219 | 222 | /** |
| 220 | - * @param $final |
|
| 221 | - * @param $payload |
|
| 222 | - * @param $opcode |
|
| 223 | - * @param $masked |
|
| 223 | + * @param boolean $final |
|
| 224 | + * @param string $payload |
|
| 225 | + * @param string $opcode |
|
| 226 | + * @param boolean $masked |
|
| 224 | 227 | * @throws ConnectionException |
| 225 | 228 | * @throws \Exception |
| 226 | 229 | */ |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | $header = 'GET ' . $path_with_query . " HTTP/1.1\r\n" |
| 116 | 116 | . implode( |
| 117 | 117 | "\r\n", array_map( |
| 118 | - function ($key, $value) { |
|
| 118 | + function($key, $value) { |
|
| 119 | 119 | return "$key: $value"; |
| 120 | 120 | }, array_keys($headers), $headers |
| 121 | 121 | ) |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | // Binary string for header. |
| 230 | 230 | $frameHeadBin = ''; |
| 231 | 231 | // Write FIN, final fragment bit. |
| 232 | - $frameHeadBin .= (bool)$final ? '1' : '0'; |
|
| 232 | + $frameHeadBin .= (bool) $final ? '1' : '0'; |
|
| 233 | 233 | // RSV 1, 2, & 3 false and unused. |
| 234 | 234 | $frameHeadBin .= '000'; |
| 235 | 235 | // Opcode rest of the byte. |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | |
| 295 | 295 | // Is this the final fragment? // Bit 0 in byte 0 |
| 296 | 296 | /// @todo Handle huge payloads with multiple fragments. |
| 297 | - $final = (bool)(ord($data[0]) & 1 << 7); |
|
| 297 | + $final = (bool) (ord($data[0]) & 1 << 7); |
|
| 298 | 298 | |
| 299 | 299 | // Should be unused, and must be false… // Bits 1, 2, & 3 |
| 300 | 300 | // $rsv1 = (boolean) (ord($data[0]) & 1 << 6); |
@@ -314,12 +314,12 @@ discard block |
||
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | // Masking? |
| 317 | - $mask = (bool)(ord($data[1]) >> 7); // Bit 0 in byte 1 |
|
| 317 | + $mask = (bool) (ord($data[1]) >> 7); // Bit 0 in byte 1 |
|
| 318 | 318 | |
| 319 | 319 | $payload = ''; |
| 320 | 320 | |
| 321 | 321 | // Payload length |
| 322 | - $payload_length = (int)ord($data[1]) & self::MASK_127; // Bits 1-7 in byte 1 |
|
| 322 | + $payload_length = (int) ord($data[1]) & self::MASK_127; // Bits 1-7 in byte 1 |
|
| 323 | 323 | if ($payload_length > self::MASK_125) { |
| 324 | 324 | if ($payload_length === self::MASK_126) { |
| 325 | 325 | $data = $this->read(2); // 126: Payload is a 16-bit unsigned int |
@@ -305,14 +305,14 @@ |
||
| 305 | 305 | private function handshake($client, string $headers) : string |
| 306 | 306 | { |
| 307 | 307 | $match = []; |
| 308 | - $key = empty($this->handshakes[(int)$client]) ? 0 : $this->handshakes[(int)$client]; |
|
| 308 | + $key = empty($this->handshakes[(int) $client]) ? 0 : $this->handshakes[(int) $client]; |
|
| 309 | 309 | preg_match(self::SEC_WEBSOCKET_KEY_PTRN, $headers, $match); |
| 310 | 310 | if (empty($match[1])) { |
| 311 | 311 | return false; |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | $key = $match[1]; |
| 315 | - $this->handshakes[(int)$client] = $key; |
|
| 315 | + $this->handshakes[(int) $client] = $key; |
|
| 316 | 316 | |
| 317 | 317 | // sending header according to WebSocket Protocol |
| 318 | 318 | $secWebSocketAccept = base64_encode(sha1(trim($key) . self::HEADER_WEBSOCKET_ACCEPT_HASH, true)); |