@@ -41,7 +41,7 @@ discard block |
||
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 |
||
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 | 108 | if (method_exists($handler, 'onHandShake')) { |
109 | - $this->swoole->on('HandShake', function () use ($eventHandler) { |
|
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 |
||
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 | } |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | 'BufferEmpty', |
169 | 169 | ]; |
170 | 170 | foreach ($events as $event) { |
171 | - $port->on($event, function () use ($event, $eventHandler) { |
|
172 | - $eventHandler('on' . $event, func_get_args()); |
|
171 | + $port->on($event, function() use ($event, $eventHandler) { |
|
172 | + $eventHandler('on'.$event, func_get_args()); |
|
173 | 173 | }); |
174 | 174 | } |
175 | 175 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | |
209 | 209 | protected function bindSwooleTables() |
210 | 210 | { |
211 | - $tables = isset($this->conf['swoole_tables']) ? (array)$this->conf['swoole_tables'] : []; |
|
211 | + $tables = isset($this->conf['swoole_tables']) ? (array) $this->conf['swoole_tables'] : []; |
|
212 | 212 | foreach ($tables as $name => $table) { |
213 | 213 | $t = new Table($table['size']); |
214 | 214 | foreach ($table['column'] as $column) { |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | if (!($listener instanceof Listener)) { |
316 | 316 | throw new \InvalidArgumentException(sprintf('%s must extend the abstract class %s', $listenerClass, Listener::class)); |
317 | 317 | } |
318 | - $this->callWithCatchException(function () use ($listener) { |
|
318 | + $this->callWithCatchException(function() use ($listener) { |
|
319 | 319 | $listener->handle(); |
320 | 320 | }, [], $event->getTries()); |
321 | 321 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | |
325 | 325 | protected function handleTask(Task $task) |
326 | 326 | { |
327 | - return $this->callWithCatchException(function () use ($task) { |
|
327 | + return $this->callWithCatchException(function() use ($task) { |
|
328 | 328 | $task->handle(); |
329 | 329 | return true; |
330 | 330 | }, [], $task->getTries()); |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | protected function fireEvent($event, $interface, array $arguments) |
334 | 334 | { |
335 | 335 | if (isset($this->conf['event_handlers'][$event])) { |
336 | - $eventHandlers = (array)$this->conf['event_handlers'][$event]; |
|
336 | + $eventHandlers = (array) $this->conf['event_handlers'][$event]; |
|
337 | 337 | foreach ($eventHandlers as $eventHandler) { |
338 | 338 | if (!isset(class_implements($eventHandler)[$interface])) { |
339 | 339 | throw new \InvalidArgumentException(sprintf( |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | ) |
344 | 344 | ); |
345 | 345 | } |
346 | - $this->callWithCatchException(function () use ($eventHandler, $arguments) { |
|
346 | + $this->callWithCatchException(function() use ($eventHandler, $arguments) { |
|
347 | 347 | call_user_func_array([(new $eventHandler), 'handle'], $arguments); |
348 | 348 | }); |
349 | 349 | } |