@@ -312,7 +312,7 @@ |
||
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | $key = $match[1]; |
| 315 | - $this->handshakes[(int)$client] = $key; |
|
| 315 | + $this->handshakes[(int) $client] = $key; |
|
| 316 | 316 | // sending header according to WebSocket Protocol |
| 317 | 317 | $secWebSocketAccept = base64_encode(sha1(trim($key) . self::HEADER_WEBSOCKET_ACCEPT_HASH, true)); |
| 318 | 318 | $this->setHeadersUpgrade($secWebSocketAccept); |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
| 136 | - * @return mixed|resource |
|
| 136 | + * @return resource|null |
|
| 137 | 137 | * @throws \InvalidArgumentException |
| 138 | 138 | */ |
| 139 | 139 | private function getStreamContext() |
@@ -237,6 +237,9 @@ discard block |
||
| 237 | 237 | return $this->options['fragment_size']; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | + /** |
|
| 241 | + * @param string $payload |
|
| 242 | + */ |
|
| 240 | 243 | public function send($payload, $opcode = CommonsContract::EVENT_TYPE_TEXT) |
| 241 | 244 | { |
| 242 | 245 | if (!$this->isConnected) { |
@@ -269,10 +272,10 @@ discard block |
||
| 269 | 272 | } |
| 270 | 273 | |
| 271 | 274 | /** |
| 272 | - * @param $final |
|
| 273 | - * @param $payload |
|
| 275 | + * @param boolean $final |
|
| 276 | + * @param string $payload |
|
| 274 | 277 | * @param $opcode |
| 275 | - * @param $masked |
|
| 278 | + * @param boolean $masked |
|
| 276 | 279 | * @throws ConnectionException |
| 277 | 280 | * @throws \Exception |
| 278 | 281 | */ |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | return 'GET ' . $pathWithQuery . " HTTP/1.1\r\n" |
| 182 | 182 | . implode( |
| 183 | 183 | "\r\n", array_map( |
| 184 | - function ($key, $value) { |
|
| 184 | + function($key, $value) { |
|
| 185 | 185 | return "$key: $value"; |
| 186 | 186 | }, array_keys($headers), $headers |
| 187 | 187 | ) |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | // Binary string for header. |
| 282 | 282 | $frameHeadBin = ''; |
| 283 | 283 | // Write FIN, final fragment bit. |
| 284 | - $frameHeadBin .= (bool)$final ? '1' : '0'; |
|
| 284 | + $frameHeadBin .= (bool) $final ? '1' : '0'; |
|
| 285 | 285 | // RSV 1, 2, & 3 false and unused. |
| 286 | 286 | $frameHeadBin .= '000'; |
| 287 | 287 | // Opcode rest of the byte. |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | |
| 352 | 352 | // Is this the final fragment? // Bit 0 in byte 0 |
| 353 | 353 | /// @todo Handle huge payloads with multiple fragments. |
| 354 | - $final = (bool)(ord($data[0]) & 1 << 7); |
|
| 354 | + $final = (bool) (ord($data[0]) & 1 << 7); |
|
| 355 | 355 | |
| 356 | 356 | // Parse opcode |
| 357 | 357 | $opcode_int = ord($data[0]) & 31; // Bits 4-7 |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | private function getPayloadData(string $data, int $payloadLength) |
| 412 | 412 | { |
| 413 | 413 | // Masking? |
| 414 | - $mask = (bool)(ord($data[1]) >> 7); // Bit 0 in byte 1 |
|
| 414 | + $mask = (bool) (ord($data[1]) >> 7); // Bit 0 in byte 1 |
|
| 415 | 415 | $payload = ''; |
| 416 | 416 | $maskingKey = ''; |
| 417 | 417 | // Get masking key. |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | */ |
| 442 | 442 | private function getPayloadLength(string $data) |
| 443 | 443 | { |
| 444 | - $payloadLength = (int)ord($data[1]) & self::MASK_127; // Bits 1-7 in byte 1 |
|
| 444 | + $payloadLength = (int) ord($data[1]) & self::MASK_127; // Bits 1-7 in byte 1 |
|
| 445 | 445 | if ($payloadLength > self::MASK_125) { |
| 446 | 446 | if ($payloadLength === self::MASK_126) { |
| 447 | 447 | $data = $this->read(2); // 126: Payload is a 16-bit unsigned int |