Passed
Push — master ( 4d03e1...2b3360 )
by Biao
04:05
created
src/Swoole/Server.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
         $ip = isset($conf['listen_ip']) ? $conf['listen_ip'] : '127.0.0.1';
39 39
         $port = isset($conf['listen_port']) ? $conf['listen_port'] : 5200;
40
-        $socketType = isset($conf['socket_type']) ? (int)$conf['socket_type'] : SWOOLE_SOCK_TCP;
40
+        $socketType = isset($conf['socket_type']) ? (int) $conf['socket_type'] : SWOOLE_SOCK_TCP;
41 41
 
42 42
         if ($socketType === SWOOLE_SOCK_UNIX_STREAM) {
43 43
             $socketDir = dirname($ip);
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
     protected function triggerWebSocketEvent($event, array $params)
95 95
     {
96
-        return $this->callWithCatchException(function () use ($event, $params) {
96
+        return $this->callWithCatchException(function() use ($event, $params) {
97 97
             $handler = $this->getWebSocketHandler();
98 98
 
99 99
             if (method_exists($handler, $event)) {
@@ -108,19 +108,19 @@  discard block
 block discarded – undo
108 108
     protected function bindWebSocketEvents()
109 109
     {
110 110
         if ($this->enableWebSocket) {
111
-            $this->swoole->on('HandShake', function () {
111
+            $this->swoole->on('HandShake', function() {
112 112
                 return $this->triggerWebSocketEvent('onHandShake', func_get_args());
113 113
             });
114 114
 
115
-            $this->swoole->on('Open', function () {
115
+            $this->swoole->on('Open', function() {
116 116
                 $this->triggerWebSocketEvent('onOpen', func_get_args());
117 117
             });
118 118
 
119
-            $this->swoole->on('Message', function () {
119
+            $this->swoole->on('Message', function() {
120 120
                 $this->triggerWebSocketEvent('onMessage', func_get_args());
121 121
             });
122 122
 
123
-            $this->swoole->on('Close', function (WebSocketServer $server, $fd, $reactorId) {
123
+            $this->swoole->on('Close', function(WebSocketServer $server, $fd, $reactorId) {
124 124
                 $clientInfo = $server->getClientInfo($fd);
125 125
                 if (isset($clientInfo['websocket_status']) && $clientInfo['websocket_status'] === \WEBSOCKET_STATUS_FRAME) {
126 126
                     $this->triggerWebSocketEvent('onClose', func_get_args());
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 
133 133
     protected function triggerPortEvent(Port $port, $handlerClass, $event, array $params)
134 134
     {
135
-        return $this->callWithCatchException(function () use ($port, $handlerClass, $event, $params) {
135
+        return $this->callWithCatchException(function() use ($port, $handlerClass, $event, $params) {
136 136
             $handler = $this->getSocketHandler($port, $handlerClass);
137 137
 
138 138
             if (method_exists($handler, $event)) {
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
                 'BufferEmpty',
178 178
             ];
179 179
             foreach ($events as $event) {
180
-                $port->on($event, function () use ($port, $handlerClass, $event) {
181
-                    $this->triggerPortEvent($port, $handlerClass, 'on' . $event, func_get_args());
180
+                $port->on($event, function() use ($port, $handlerClass, $event) {
181
+                    $this->triggerPortEvent($port, $handlerClass, 'on'.$event, func_get_args());
182 182
                 });
183 183
             }
184 184
         }
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 
228 228
     protected function bindSwooleTables()
229 229
     {
230
-        $tables = isset($this->conf['swoole_tables']) ? (array)$this->conf['swoole_tables'] : [];
230
+        $tables = isset($this->conf['swoole_tables']) ? (array) $this->conf['swoole_tables'] : [];
231 231
         foreach ($tables as $name => $table) {
232 232
             $t = new Table($table['size']);
233 233
             foreach ($table['column'] as $column) {
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
         $headers = [
325 325
             'Upgrade'               => 'websocket',
326 326
             'Connection'            => 'Upgrade',
327
-            'Sec-WebSocket-Accept'  => base64_encode(sha1($secKey . '258EAFA5-E914-47DA-95CA-C5AB0DC85B11', true)),
327
+            'Sec-WebSocket-Accept'  => base64_encode(sha1($secKey.'258EAFA5-E914-47DA-95CA-C5AB0DC85B11', true)),
328 328
             'Sec-WebSocket-Version' => '13',
329 329
         ];
330 330
 
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
             if (!($listener instanceof Listener)) {
371 371
                 throw new \InvalidArgumentException(sprintf('%s must extend the abstract class %s', $listenerClass, Listener::class));
372 372
             }
373
-            $this->callWithCatchException(function () use ($listener) {
373
+            $this->callWithCatchException(function() use ($listener) {
374 374
                 $listener->handle();
375 375
             }, [], $event->getTries());
376 376
         }
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 
380 380
     protected function handleTask(Task $task)
381 381
     {
382
-        return $this->callWithCatchException(function () use ($task) {
382
+        return $this->callWithCatchException(function() use ($task) {
383 383
             $task->handle();
384 384
             return true;
385 385
         }, [], $task->getTries());
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
     protected function fireEvent($event, $interface, array $arguments)
389 389
     {
390 390
         if (isset($this->conf['event_handlers'][$event])) {
391
-            $eventHandlers = (array)$this->conf['event_handlers'][$event];
391
+            $eventHandlers = (array) $this->conf['event_handlers'][$event];
392 392
             foreach ($eventHandlers as $eventHandler) {
393 393
                 if (!isset(class_implements($eventHandler)[$interface])) {
394 394
                     throw new \InvalidArgumentException(sprintf(
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
                         )
399 399
                     );
400 400
                 }
401
-                $this->callWithCatchException(function () use ($eventHandler, $arguments) {
401
+                $this->callWithCatchException(function() use ($eventHandler, $arguments) {
402 402
                     call_user_func_array([(new $eventHandler), 'handle'], $arguments);
403 403
                 });
404 404
             }
Please login to merge, or discard this patch.