Passed
Push — master ( 2288d6...24dafe )
by Biao
05:23
created
src/Swoole/Server.php 1 patch
Spacing   +17 added lines, -17 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 ($method, array $params) use ($port, $handlerClass) {
159
+            $eventHandler = function($method, array $params) use ($port, $handlerClass) {
160 160
                 $handler = $this->getSocketHandler($port, $handlerClass);
161
-                return $this->callWithCatchException(function () use ($handler, $method, $params) {
161
+                return $this->callWithCatchException(function() use ($handler, $method, $params) {
162 162
                     if (method_exists($handler, $method)) {
163 163
                         return call_user_func_array([$handler, $method], $params);
164 164
                     }
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
                 'BufferEmpty',
189 189
             ];
190 190
             foreach ($events as $event) {
191
-                $port->on($event, function () use ($event, $eventHandler) {
192
-                    return $eventHandler('on' . $event, func_get_args());
191
+                $port->on($event, function() use ($event, $eventHandler) {
192
+                    return $eventHandler('on'.$event, func_get_args());
193 193
                 });
194 194
             }
195 195
         }
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 
229 229
     protected function bindSwooleTables()
230 230
     {
231
-        $tables = isset($this->conf['swoole_tables']) ? (array)$this->conf['swoole_tables'] : [];
231
+        $tables = isset($this->conf['swoole_tables']) ? (array) $this->conf['swoole_tables'] : [];
232 232
         foreach ($tables as $name => $table) {
233 233
             $t = new Table($table['size']);
234 234
             foreach ($table['column'] as $column) {
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
         $headers = [
326 326
             'Upgrade'               => 'websocket',
327 327
             'Connection'            => 'Upgrade',
328
-            'Sec-WebSocket-Accept'  => base64_encode(sha1($secKey . '258EAFA5-E914-47DA-95CA-C5AB0DC85B11', true)),
328
+            'Sec-WebSocket-Accept'  => base64_encode(sha1($secKey.'258EAFA5-E914-47DA-95CA-C5AB0DC85B11', true)),
329 329
             'Sec-WebSocket-Version' => '13',
330 330
         ];
331 331
 
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 
346 346
         if (is_callable($onOpen)) {
347 347
             if (method_exists($this->swoole, 'defer')) {
348
-                $this->swoole->defer(function () use ($onOpen, $request) {
348
+                $this->swoole->defer(function() use ($onOpen, $request) {
349 349
                     call_user_func($onOpen, $this->swoole, $request);
350 350
                 });
351 351
             } else {
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
             if (!($listener instanceof Listener)) {
383 383
                 throw new \InvalidArgumentException(sprintf('%s must extend the abstract class %s', $listenerClass, Listener::class));
384 384
             }
385
-            $this->callWithCatchException(function () use ($listener) {
385
+            $this->callWithCatchException(function() use ($listener) {
386 386
                 $listener->handle();
387 387
             }, [], $event->getTries());
388 388
         }
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 
392 392
     protected function handleTask(Task $task)
393 393
     {
394
-        return $this->callWithCatchException(function () use ($task) {
394
+        return $this->callWithCatchException(function() use ($task) {
395 395
             $task->handle();
396 396
             return true;
397 397
         }, [], $task->getTries());
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
     protected function fireEvent($event, $interface, array $arguments)
401 401
     {
402 402
         if (isset($this->conf['event_handlers'][$event])) {
403
-            $eventHandlers = (array)$this->conf['event_handlers'][$event];
403
+            $eventHandlers = (array) $this->conf['event_handlers'][$event];
404 404
             foreach ($eventHandlers as $eventHandler) {
405 405
                 if (!isset(class_implements($eventHandler)[$interface])) {
406 406
                     throw new \InvalidArgumentException(sprintf(
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
                         )
411 411
                     );
412 412
                 }
413
-                $this->callWithCatchException(function () use ($eventHandler, $arguments) {
413
+                $this->callWithCatchException(function() use ($eventHandler, $arguments) {
414 414
                     call_user_func_array([(new $eventHandler), 'handle'], $arguments);
415 415
                 });
416 416
             }
Please login to merge, or discard this patch.