Passed
Push — master ( 5e8674...3117ac )
by Marco
02:18
created
src/Comodojo/Daemon/Socket/Server.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 
170 170
             do {
171 171
                 $this->loop();
172
-            } while ($this->active);
172
+            } while ( $this->active );
173 173
 
174 174
         } catch (Exception $e) {
175 175
 
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 
206 206
         $select = @socket_select($sockets, $write, $except, $this->timeout);
207 207
 
208
-        if ($select === false) {
208
+        if ( $select === false ) {
209 209
 
210 210
             if ( $this->checkSocketError() && $this->active ) {
211 211
                 $this->logger->debug("Socket reset due to incoming signal");
@@ -219,13 +219,13 @@  discard block
 block discarded – undo
219 219
 
220 220
         }
221 221
 
222
-        if( $select < 1 ) {
222
+        if ( $select < 1 ) {
223 223
             return;
224 224
         }
225 225
 
226
-        if( in_array($this->socket, $sockets) ) {
226
+        if ( in_array($this->socket, $sockets) ) {
227 227
 
228
-            for ($i=0; $i < $select; $i++) {
228
+            for ( $i = 0; $i < $select; $i++ ) {
229 229
 
230 230
                 if ( empty($this->connections[$i]) ) {
231 231
 
@@ -251,17 +251,17 @@  discard block
 block discarded – undo
251 251
 
252 252
         }
253 253
 
254
-        for ($i = 0; $i < $this->max_connections; $i++) {
254
+        for ( $i = 0; $i < $this->max_connections; $i++ ) {
255 255
 
256
-            if (isset($this->connections[$i])) {
256
+            if ( isset($this->connections[$i]) ) {
257 257
 
258 258
                 $client = $this->connections[$i];
259 259
 
260
-                if (in_array($client->getSocket(), $sockets)) {
260
+                if ( in_array($client->getSocket(), $sockets) ) {
261 261
 
262 262
                     $message = $this->read($client);
263 263
 
264
-                    if ($message === null) {
264
+                    if ( $message === null ) {
265 265
                     // if ($message == null) {
266 266
                          $this->hangup($client);
267 267
                     } else if ( $message === false ) {
@@ -293,16 +293,16 @@  discard block
 block discarded – undo
293 293
         $datagram = '';
294 294
         $socket = $connection->getSocket();
295 295
 
296
-        while (true) {
296
+        while ( true ) {
297 297
             $recv = @socket_read($socket, $this->read_buffer, PHP_NORMAL_READ);
298 298
             if ( $recv === false ) return null;
299 299
             $datagram .= $recv;
300
-            if (empty($recv) || strstr($recv, PHP_EOL)) break;
300
+            if ( empty($recv) || strstr($recv, PHP_EOL) ) break;
301 301
         }
302 302
 
303 303
         $datagram = trim($datagram);
304 304
 
305
-        if ( !empty($datagram) && $datagram !== false) {
305
+        if ( !empty($datagram) && $datagram !== false ) {
306 306
 
307 307
             $message = new Request();
308 308
 
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 
324 324
         $response = new Response();
325 325
 
326
-        if ( $request->content_type == 'application/json') {
326
+        if ( $request->content_type == 'application/json' ) {
327 327
             $this->rpc_server->setProtocol(RpcServer::JSONRPC);
328 328
         }
329 329
 
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 
353 353
         $this->logger->debug("Opening connection ($idx), sending greeter");
354 354
 
355
-        $this->events->emit( new SocketEvent('client.connect', $this->process) );
355
+        $this->events->emit(new SocketEvent('client.connect', $this->process));
356 356
 
357 357
         $message = new Greeter();
358 358
 
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         $this->connections[$index]->destroy();
372 372
         unset($this->connections[$index]);
373 373
 
374
-        $this->events->emit( new SocketEvent('client.hangup', $this->process) );
374
+        $this->events->emit(new SocketEvent('client.hangup', $this->process));
375 375
 
376 376
     }
377 377
 
Please login to merge, or discard this patch.