Passed
Pull Request — master (#322)
by
unknown
06:51 queued 03:20
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);
@@ -98,28 +98,28 @@  discard block
 block discarded – undo
98 98
     protected function bindWebSocketEvent()
99 99
     {
100 100
         if ($this->enableWebSocket) {
101
-            $eventHandler = function ($method, array $params) {
102
-                $this->callWithCatchException(function () use ($method, $params) {
101
+            $eventHandler = function($method, array $params) {
102
+                $this->callWithCatchException(function() use ($method, $params) {
103 103
                     call_user_func_array([$this->getWebSocketHandler(), $method], $params);
104 104
                 });
105 105
             };
106 106
 
107 107
             $handler = $this->getWebSocketHandler();
108
-            if (method_exists($handler, 'onHandShake')){
109
-                $this->swoole->on('handshake', function () use ($eventHandler){
108
+            if (method_exists($handler, 'onHandShake')) {
109
+                $this->swoole->on('handshake', function() use ($eventHandler){
110 110
                     $eventHandler('onHandShake', func_get_args());
111 111
                 });
112 112
             }
113 113
 
114
-            $this->swoole->on('Open', function () use ($eventHandler) {
114
+            $this->swoole->on('Open', function() use ($eventHandler) {
115 115
                 $eventHandler('onOpen', func_get_args());
116 116
             });
117 117
 
118
-            $this->swoole->on('Message', function () use ($eventHandler) {
118
+            $this->swoole->on('Message', function() use ($eventHandler) {
119 119
                 $eventHandler('onMessage', func_get_args());
120 120
             });
121 121
 
122
-            $this->swoole->on('Close', function (WebSocketServer $server, $fd, $reactorId) use ($eventHandler) {
122
+            $this->swoole->on('Close', function(WebSocketServer $server, $fd, $reactorId) use ($eventHandler) {
123 123
                 $clientInfo = $server->getClientInfo($fd);
124 124
                 if (isset($clientInfo['websocket_status']) && $clientInfo['websocket_status'] === \WEBSOCKET_STATUS_FRAME) {
125 125
                     $eventHandler('onClose', func_get_args());
@@ -147,10 +147,10 @@  discard block
 block discarded – undo
147 147
             $port->set(empty($socket['settings']) ? [] : $socket['settings']);
148 148
 
149 149
             $handlerClass = $socket['handler'];
150
-            $eventHandler = function ($method, array $params) use ($port, $handlerClass) {
150
+            $eventHandler = function($method, array $params) use ($port, $handlerClass) {
151 151
                 $handler = $this->getSocketHandler($port, $handlerClass);
152 152
                 if (method_exists($handler, $method)) {
153
-                    $this->callWithCatchException(function () use ($handler, $method, $params) {
153
+                    $this->callWithCatchException(function() use ($handler, $method, $params) {
154 154
                         call_user_func_array([$handler, $method], $params);
155 155
                     });
156 156
                 }
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
                 'BufferEmpty',
168 168
             ];
169 169
             foreach ($events as $event) {
170
-                $port->on($event, function () use ($event, $eventHandler) {
171
-                    $eventHandler('on' . $event, func_get_args());
170
+                $port->on($event, function() use ($event, $eventHandler) {
171
+                    $eventHandler('on'.$event, func_get_args());
172 172
                 });
173 173
             }
174 174
         }
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 
208 208
     protected function bindSwooleTables()
209 209
     {
210
-        $tables = isset($this->conf['swoole_tables']) ? (array)$this->conf['swoole_tables'] : [];
210
+        $tables = isset($this->conf['swoole_tables']) ? (array) $this->conf['swoole_tables'] : [];
211 211
         foreach ($tables as $name => $table) {
212 212
             $t = new Table($table['size']);
213 213
             foreach ($table['column'] as $column) {
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
             if (!($listener instanceof Listener)) {
315 315
                 throw new \InvalidArgumentException(sprintf('%s must extend the abstract class %s', $listenerClass, Listener::class));
316 316
             }
317
-            $this->callWithCatchException(function () use ($listener) {
317
+            $this->callWithCatchException(function() use ($listener) {
318 318
                 $listener->handle();
319 319
             }, [], $event->getTries());
320 320
         }
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 
324 324
     protected function handleTask(Task $task)
325 325
     {
326
-        return $this->callWithCatchException(function () use ($task) {
326
+        return $this->callWithCatchException(function() use ($task) {
327 327
             $task->handle();
328 328
             return true;
329 329
         }, [], $task->getTries());
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
     protected function fireEvent($event, $interface, array $arguments)
333 333
     {
334 334
         if (isset($this->conf['event_handlers'][$event])) {
335
-            $eventHandlers = (array)$this->conf['event_handlers'][$event];
335
+            $eventHandlers = (array) $this->conf['event_handlers'][$event];
336 336
             foreach ($eventHandlers as $eventHandler) {
337 337
                 if (!isset(class_implements($eventHandler)[$interface])) {
338 338
                     throw new \InvalidArgumentException(sprintf(
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
                         )
343 343
                     );
344 344
                 }
345
-                $this->callWithCatchException(function () use ($eventHandler, $arguments) {
345
+                $this->callWithCatchException(function() use ($eventHandler, $arguments) {
346 346
                     call_user_func_array([(new $eventHandler), 'handle'], $arguments);
347 347
                 });
348 348
             }
Please login to merge, or discard this patch.