@@ -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); |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
| 114 | - * @return mixed|resource |
|
| 114 | + * @return resource|null |
|
| 115 | 115 | * @throws \InvalidArgumentException |
| 116 | 116 | */ |
| 117 | 117 | private function getStreamContext() |
@@ -211,6 +211,9 @@ discard block |
||
| 211 | 211 | return $this->options['fragment_size']; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | + /** |
|
| 215 | + * @param string $payload |
|
| 216 | + */ |
|
| 214 | 217 | public function send($payload, $opcode = 'text', $masked = true) |
| 215 | 218 | { |
| 216 | 219 | if (!$this->isConnected) { |
@@ -244,10 +247,10 @@ discard block |
||
| 244 | 247 | } |
| 245 | 248 | |
| 246 | 249 | /** |
| 247 | - * @param $final |
|
| 248 | - * @param $payload |
|
| 249 | - * @param $opcode |
|
| 250 | - * @param $masked |
|
| 250 | + * @param boolean $final |
|
| 251 | + * @param string $payload |
|
| 252 | + * @param string $opcode |
|
| 253 | + * @param boolean $masked |
|
| 251 | 254 | * @throws ConnectionException |
| 252 | 255 | * @throws \Exception |
| 253 | 256 | */ |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | return 'GET ' . $pathWithQuery . " HTTP/1.1\r\n" |
| 160 | 160 | . implode( |
| 161 | 161 | "\r\n", array_map( |
| 162 | - function ($key, $value) { |
|
| 162 | + function($key, $value) { |
|
| 163 | 163 | return "$key: $value"; |
| 164 | 164 | }, array_keys($headers), $headers |
| 165 | 165 | ) |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | // Binary string for header. |
| 261 | 261 | $frameHeadBin = ''; |
| 262 | 262 | // Write FIN, final fragment bit. |
| 263 | - $frameHeadBin .= (bool)$final ? '1' : '0'; |
|
| 263 | + $frameHeadBin .= (bool) $final ? '1' : '0'; |
|
| 264 | 264 | // RSV 1, 2, & 3 false and unused. |
| 265 | 265 | $frameHeadBin .= '000'; |
| 266 | 266 | // Opcode rest of the byte. |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | |
| 331 | 331 | // Is this the final fragment? // Bit 0 in byte 0 |
| 332 | 332 | /// @todo Handle huge payloads with multiple fragments. |
| 333 | - $final = (bool)(ord($data[0]) & 1 << 7); |
|
| 333 | + $final = (bool) (ord($data[0]) & 1 << 7); |
|
| 334 | 334 | |
| 335 | 335 | // Parse opcode |
| 336 | 336 | $opcode_int = ord($data[0]) & 31; // Bits 4-7 |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | private function getPayloadData(string $data, int $payloadLength) |
| 391 | 391 | { |
| 392 | 392 | // Masking? |
| 393 | - $mask = (bool)(ord($data[1]) >> 7); // Bit 0 in byte 1 |
|
| 393 | + $mask = (bool) (ord($data[1]) >> 7); // Bit 0 in byte 1 |
|
| 394 | 394 | $payload = ''; |
| 395 | 395 | $maskingKey = ''; |
| 396 | 396 | // Get masking key. |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | */ |
| 421 | 421 | private function getPayloadLength(string $data) |
| 422 | 422 | { |
| 423 | - $payloadLength = (int)ord($data[1]) & self::MASK_127; // Bits 1-7 in byte 1 |
|
| 423 | + $payloadLength = (int) ord($data[1]) & self::MASK_127; // Bits 1-7 in byte 1 |
|
| 424 | 424 | if ($payloadLength > self::MASK_125) { |
| 425 | 425 | if ($payloadLength === self::MASK_126) { |
| 426 | 426 | $data = $this->read(2); // 126: Payload is a 16-bit unsigned int |