Completed
Pull Request — master (#40)
by
unknown
01:42
created
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.
src/Components/WSClientTrait.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -184,10 +184,10 @@
 block discarded – undo
184 184
     }
185 185
 
186 186
     /**
187
-     * @param $final
188
-     * @param $payload
189
-     * @param $opcode
190
-     * @param $masked
187
+     * @param boolean $final
188
+     * @param string $payload
189
+     * @param string $opcode
190
+     * @param boolean $masked
191 191
      * @throws ConnectionException
192 192
      * @throws \Exception
193 193
      */
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      */
64 64
     private function getPayloadLength(string $data)
65 65
     {
66
-        $payloadLength = (int)ord($data[1]) & self::MASK_127; // Bits 1-7 in byte 1
66
+        $payloadLength = (int) ord($data[1]) & self::MASK_127; // Bits 1-7 in byte 1
67 67
         if ($payloadLength > self::MASK_125) {
68 68
             if ($payloadLength === self::MASK_126) {
69 69
                 $data = $this->read(2); // 126: Payload is a 16-bit unsigned int
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     private function getPayloadData(string $data, int $payloadLength): string
86 86
     {
87 87
         // Masking?
88
-        $mask = (bool)(ord($data[1]) >> 7);  // Bit 0 in byte 1
88
+        $mask = (bool) (ord($data[1]) >> 7); // Bit 0 in byte 1
89 89
         $payload = '';
90 90
         $maskingKey = '';
91 91
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 
128 128
         // Is this the final fragment?  // Bit 0 in byte 0
129 129
         /// @todo Handle huge payloads with multiple fragments.
130
-        $final = (bool)(ord($data[0]) & 1 << 7);
130
+        $final = (bool) (ord($data[0]) & 1 << 7);
131 131
 
132 132
         // Parse opcode
133 133
         $opcode_int = ord($data[0]) & 31; // Bits 4-7
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         // Binary string for header.
197 197
         $frameHeadBin = '';
198 198
         // Write FIN, final fragment bit.
199
-        $frameHeadBin .= (bool)$final ? '1' : '0';
199
+        $frameHeadBin .= (bool) $final ? '1' : '0';
200 200
         // RSV 1, 2, & 3 false and unused.
201 201
         $frameHeadBin .= '000';
202 202
         // Opcode rest of the byte.
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
@@ -69,7 +69,7 @@
 block discarded – undo
69 69
         $server = stream_socket_server("tcp://{$this->config->getHost()}:{$this->config->getPort()}", $errno, $errorMessage);
70 70
 
71 71
         if ($server === false) {
72
-           throw new WebSocketException('Could not bind to socket: ' . $errno . ' - ' . $errorMessage . PHP_EOL, CommonsContract::SERVER_COULD_NOT_BIND_TO_SOCKET);
72
+            throw new WebSocketException('Could not bind to socket: ' . $errno . ' - ' . $errorMessage . PHP_EOL, CommonsContract::SERVER_COULD_NOT_BIND_TO_SOCKET);
73 73
         }
74 74
 
75 75
         @cli_set_process_title($this->config->getProcessName());
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     private const HEADER_BYTES_READ = 1024;
38 38
 
39 39
     // stream non-blocking
40
-    public const NON_BLOCK  = 0;
40
+    public const NON_BLOCK = 0;
41 41
 
42 42
     /**
43 43
      * WebSocketServer constructor.
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
         }
335 335
 
336 336
         $key = $match[1];
337
-        $this->handshakes[(int)$client] = $key;
337
+        $this->handshakes[(int) $client] = $key;
338 338
 
339 339
         // sending header according to WebSocket Protocol
340 340
         $secWebSocketAccept = base64_encode(sha1(trim($key) . self::HEADER_WEBSOCKET_ACCEPT_HASH, true));
Please login to merge, or discard this patch.
src/Contracts/WebSocketServerContract.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,10 +22,10 @@
 block discarded – undo
22 22
     public const HEADER_HTTP1_1                   = 'HTTP/1.1 101 Web Socket Protocol Handshake';
23 23
     public const HEADER_WEBSOCKET_ACCEPT_HASH     = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11';
24 24
     public const HEADERS_UPGRADE_KEY              = 'Upgrade',
25
-                 HEADERS_CONNECTION_KEY           = 'Connection',
26
-                 HEADERS_SEC_WEBSOCKET_ACCEPT_KEY = 'Sec-WebSocket-Accept';
25
+                    HEADERS_CONNECTION_KEY           = 'Connection',
26
+                    HEADERS_SEC_WEBSOCKET_ACCEPT_KEY = 'Sec-WebSocket-Accept';
27 27
     public const HEADERS_UPGRADE_VALUE            = 'websocket',
28
-                 HEADERS_CONNECTION_VALUE         = 'Upgrade';
28
+                    HEADERS_CONNECTION_VALUE         = 'Upgrade';
29 29
     public const HEADERS_EOL                      = "\r\n";
30 30
     public const SEC_WEBSOCKET_KEY_PTRN           = '/Sec-WebSocket-Key:\s(.*)\n/';
31 31
 
Please login to merge, or discard this patch.
src/Components/WscMain.php 2 patches
Doc Comments   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -124,6 +124,9 @@  discard block
 block discarded – undo
124 124
     }
125 125
 
126 126
 
127
+    /**
128
+     * @param string $host
129
+     */
127 130
     private function proxy($host, $ip, $port, $auth)
128 131
     {
129 132
         // Set the stream context options if they're already set in the config
@@ -154,7 +157,7 @@  discard block
 block discarded – undo
154 157
 
155 158
 
156 159
     /**
157
-     * @return mixed|resource
160
+     * @return resource|null
158 161
      * @throws \InvalidArgumentException
159 162
      */
160 163
     private function getStreamContext()
@@ -257,7 +260,7 @@  discard block
 block discarded – undo
257 260
     /**
258 261
      * Sends message to opened socket connection client->server
259 262
      *
260
-     * @param $payload
263
+     * @param string $payload
261 264
      * @param string $opcode
262 265
      * @throws \InvalidArgumentException
263 266
      * @throws BadOpcodeException
@@ -329,7 +332,7 @@  discard block
 block discarded – undo
329 332
      *
330 333
      * @param integer $status http://tools.ietf.org/html/rfc6455#section-7.4
331 334
      * @param string $message A closing message, max 125 bytes.
332
-     * @return bool|null|string
335
+     * @return null|string
333 336
      * @throws \InvalidArgumentException
334 337
      * @throws BadOpcodeException
335 338
      * @throws BadUriException
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
             $context
138 138
         );
139 139
 
140
-        $write =  "CONNECT $host HTTP/1.1\r\n";
140
+        $write = "CONNECT $host HTTP/1.1\r\n";
141 141
         if ($auth) {
142 142
             $write .= "Proxy-Authorization: Basic $auth\r\n";
143 143
         }
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
             . implode(
206 206
                 "\r\n",
207 207
                 array_map(
208
-                    function ($key, $value) {
208
+                    function($key, $value) {
209 209
                         return "$key: $value";
210 210
                     },
211 211
                     array_keys($headers),
Please login to merge, or discard this patch.
src/Components/ClientConfig.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -190,7 +190,7 @@
 block discarded – undo
190 190
         $this->has_proxy = true;
191 191
         $this->proxy_ip = $ip;
192 192
         $this->proxy_port = $port;
193
-        $this->proxy_auth = ($username && $password) ? base64_encode($username.':'.$password) : null;
193
+        $this->proxy_auth = ($username && $password) ? base64_encode($username . ':' . $password) : null;
194 194
     }
195 195
 
196 196
     public function getProxy(&$ip, &$port, &$auth)
Please login to merge, or discard this patch.