Passed
Push — master ( 24dafe...4d03e1 )
by Biao
04:40
created
src/Swoole/Server.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 
42 42
         $ip = isset($conf['listen_ip']) ? $conf['listen_ip'] : '127.0.0.1';
43 43
         $port = isset($conf['listen_port']) ? $conf['listen_port'] : 5200;
44
-        $socketType = isset($conf['socket_type']) ? (int)$conf['socket_type'] : SWOOLE_SOCK_TCP;
44
+        $socketType = isset($conf['socket_type']) ? (int) $conf['socket_type'] : SWOOLE_SOCK_TCP;
45 45
 
46 46
         if ($socketType === SWOOLE_SOCK_UNIX_STREAM) {
47 47
             $socketDir = dirname($ip);
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
     protected function triggerWebSocketEvent($event, array $params)
99 99
     {
100
-        return $this->callWithCatchException(function () use ($event, $params) {
100
+        return $this->callWithCatchException(function() use ($event, $params) {
101 101
             $handler = $this->getWebSocketHandler();
102 102
 
103 103
             if (method_exists($handler, $event)) {
@@ -116,19 +116,19 @@  discard block
 block discarded – undo
116 116
     protected function bindWebSocketEvents()
117 117
     {
118 118
         if ($this->enableWebSocket) {
119
-            $this->swoole->on('HandShake', function () {
119
+            $this->swoole->on('HandShake', function() {
120 120
                 return $this->triggerWebSocketEvent('onHandShake', func_get_args());
121 121
             });
122 122
 
123
-            $this->swoole->on('Open', function () {
123
+            $this->swoole->on('Open', function() {
124 124
                 $this->triggerWebSocketEvent('onOpen', func_get_args());
125 125
             });
126 126
 
127
-            $this->swoole->on('Message', function () {
127
+            $this->swoole->on('Message', function() {
128 128
                 $this->triggerWebSocketEvent('onMessage', func_get_args());
129 129
             });
130 130
 
131
-            $this->swoole->on('Close', function (WebSocketServer $server, $fd, $reactorId) {
131
+            $this->swoole->on('Close', function(WebSocketServer $server, $fd, $reactorId) {
132 132
                 $clientInfo = $server->getClientInfo($fd);
133 133
                 if (isset($clientInfo['websocket_status']) && $clientInfo['websocket_status'] === \WEBSOCKET_STATUS_FRAME) {
134 134
                     $this->triggerWebSocketEvent('onClose', func_get_args());
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
             $port->set(empty($socket['settings']) ? [] : $socket['settings']);
157 157
 
158 158
             $handlerClass = $socket['handler'];
159
-            $eventHandler = function ($event, array $params) use ($port, $handlerClass) {
159
+            $eventHandler = function($event, array $params) use ($port, $handlerClass) {
160 160
                 $handler = $this->getSocketHandler($port, $handlerClass);
161
-                return $this->callWithCatchException(function () use ($handler, $event, $params) {
161
+                return $this->callWithCatchException(function() use ($handler, $event, $params) {
162 162
                     if (method_exists($handler, $event)) {
163 163
                         if ($event === 'onHandShake' || $event === 'onRequest') {
164 164
                             $this->startHandleHttp($params[0]);
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
                     // Set default HandShake
185 185
                     if ($event === 'onHandShake' && method_exists($handler, 'onOpen')) {
186 186
                         $this->startHandleHttp($params[0]);
187
-                        $params[] = function () use ($handler, $params) {
187
+                        $params[] = function() use ($handler, $params) {
188 188
                             call_user_func_array([$handler, 'onOpen'], func_get_args());
189 189
                             $this->endHandleHttp($params[0]);
190 190
                         };
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
                 'BufferEmpty',
209 209
             ];
210 210
             foreach ($events as $event) {
211
-                $port->on($event, function () use ($event, $eventHandler) {
212
-                    return $eventHandler('on' . $event, func_get_args());
211
+                $port->on($event, function() use ($event, $eventHandler) {
212
+                    return $eventHandler('on'.$event, func_get_args());
213 213
                 });
214 214
             }
215 215
         }
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 
259 259
     protected function bindSwooleTables()
260 260
     {
261
-        $tables = isset($this->conf['swoole_tables']) ? (array)$this->conf['swoole_tables'] : [];
261
+        $tables = isset($this->conf['swoole_tables']) ? (array) $this->conf['swoole_tables'] : [];
262 262
         foreach ($tables as $name => $table) {
263 263
             $t = new Table($table['size']);
264 264
             foreach ($table['column'] as $column) {
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
         $headers = [
356 356
             'Upgrade'               => 'websocket',
357 357
             'Connection'            => 'Upgrade',
358
-            'Sec-WebSocket-Accept'  => base64_encode(sha1($secKey . '258EAFA5-E914-47DA-95CA-C5AB0DC85B11', true)),
358
+            'Sec-WebSocket-Accept'  => base64_encode(sha1($secKey.'258EAFA5-E914-47DA-95CA-C5AB0DC85B11', true)),
359 359
             'Sec-WebSocket-Version' => '13',
360 360
         ];
361 361
 
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 
376 376
         if (is_callable($onOpen)) {
377 377
             if (method_exists($this->swoole, 'defer')) {
378
-                $this->swoole->defer(function () use ($onOpen, $request) {
378
+                $this->swoole->defer(function() use ($onOpen, $request) {
379 379
                     call_user_func($onOpen, $this->swoole, $request);
380 380
                 });
381 381
             } else {
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
             if (!($listener instanceof Listener)) {
413 413
                 throw new \InvalidArgumentException(sprintf('%s must extend the abstract class %s', $listenerClass, Listener::class));
414 414
             }
415
-            $this->callWithCatchException(function () use ($listener) {
415
+            $this->callWithCatchException(function() use ($listener) {
416 416
                 $listener->handle();
417 417
             }, [], $event->getTries());
418 418
         }
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 
422 422
     protected function handleTask(Task $task)
423 423
     {
424
-        return $this->callWithCatchException(function () use ($task) {
424
+        return $this->callWithCatchException(function() use ($task) {
425 425
             $task->handle();
426 426
             return true;
427 427
         }, [], $task->getTries());
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
     protected function fireEvent($event, $interface, array $arguments)
431 431
     {
432 432
         if (isset($this->conf['event_handlers'][$event])) {
433
-            $eventHandlers = (array)$this->conf['event_handlers'][$event];
433
+            $eventHandlers = (array) $this->conf['event_handlers'][$event];
434 434
             foreach ($eventHandlers as $eventHandler) {
435 435
                 if (!isset(class_implements($eventHandler)[$interface])) {
436 436
                     throw new \InvalidArgumentException(sprintf(
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
                         )
441 441
                     );
442 442
                 }
443
-                $this->callWithCatchException(function () use ($eventHandler, $arguments) {
443
+                $this->callWithCatchException(function() use ($eventHandler, $arguments) {
444 444
                     call_user_func_array([(new $eventHandler), 'handle'], $arguments);
445 445
                 });
446 446
             }
Please login to merge, or discard this patch.