@@ -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,21 +98,21 @@ 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 | - $this->swoole->on('Open', function () use ($eventHandler) { |
|
| 107 | + $this->swoole->on('Open', function() use ($eventHandler) { |
|
| 108 | 108 | $eventHandler('onOpen', func_get_args()); |
| 109 | 109 | }); |
| 110 | 110 | |
| 111 | - $this->swoole->on('Message', function () use ($eventHandler) { |
|
| 111 | + $this->swoole->on('Message', function() use ($eventHandler) { |
|
| 112 | 112 | $eventHandler('onMessage', func_get_args()); |
| 113 | 113 | }); |
| 114 | 114 | |
| 115 | - $this->swoole->on('Close', function (WebSocketServer $server, $fd, $reactorId) use ($eventHandler) { |
|
| 115 | + $this->swoole->on('Close', function(WebSocketServer $server, $fd, $reactorId) use ($eventHandler) { |
|
| 116 | 116 | $clientInfo = $server->getClientInfo($fd); |
| 117 | 117 | if (isset($clientInfo['websocket_status']) && $clientInfo['websocket_status'] === \WEBSOCKET_STATUS_FRAME) { |
| 118 | 118 | $eventHandler('onClose', func_get_args()); |
@@ -140,10 +140,10 @@ discard block |
||
| 140 | 140 | $port->set(empty($socket['settings']) ? [] : $socket['settings']); |
| 141 | 141 | |
| 142 | 142 | $handlerClass = $socket['handler']; |
| 143 | - $eventHandler = function ($method, array $params) use ($port, $handlerClass) { |
|
| 143 | + $eventHandler = function($method, array $params) use ($port, $handlerClass) { |
|
| 144 | 144 | $handler = $this->getSocketHandler($port, $handlerClass); |
| 145 | 145 | if (method_exists($handler, $method)) { |
| 146 | - $this->callWithCatchException(function () use ($handler, $method, $params) { |
|
| 146 | + $this->callWithCatchException(function() use ($handler, $method, $params) { |
|
| 147 | 147 | call_user_func_array([$handler, $method], $params); |
| 148 | 148 | }); |
| 149 | 149 | } |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | 'BufferEmpty', |
| 161 | 161 | ]; |
| 162 | 162 | foreach ($events as $event) { |
| 163 | - $port->on($event, function () use ($event, $eventHandler) { |
|
| 164 | - $eventHandler('on' . $event, func_get_args()); |
|
| 163 | + $port->on($event, function() use ($event, $eventHandler) { |
|
| 164 | + $eventHandler('on'.$event, func_get_args()); |
|
| 165 | 165 | }); |
| 166 | 166 | } |
| 167 | 167 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | |
| 201 | 201 | protected function bindSwooleTables() |
| 202 | 202 | { |
| 203 | - $tables = isset($this->conf['swoole_tables']) ? (array)$this->conf['swoole_tables'] : []; |
|
| 203 | + $tables = isset($this->conf['swoole_tables']) ? (array) $this->conf['swoole_tables'] : []; |
|
| 204 | 204 | foreach ($tables as $name => $table) { |
| 205 | 205 | $t = new Table($table['size']); |
| 206 | 206 | foreach ($table['column'] as $column) { |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | if (!($listener instanceof Listener)) { |
| 308 | 308 | throw new \InvalidArgumentException(sprintf('%s must extend the abstract class %s', $listenerClass, Listener::class)); |
| 309 | 309 | } |
| 310 | - $this->callWithCatchException(function () use ($listener) { |
|
| 310 | + $this->callWithCatchException(function() use ($listener) { |
|
| 311 | 311 | $listener->handle(); |
| 312 | 312 | }, [], $event->getTries()); |
| 313 | 313 | } |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | |
| 317 | 317 | protected function handleTask(Task $task) |
| 318 | 318 | { |
| 319 | - return $this->callWithCatchException(function () use ($task) { |
|
| 319 | + return $this->callWithCatchException(function() use ($task) { |
|
| 320 | 320 | $task->handle(); |
| 321 | 321 | return true; |
| 322 | 322 | }, [], $task->getTries()); |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | protected function fireEvent($event, $interface, array $arguments) |
| 326 | 326 | { |
| 327 | 327 | if (isset($this->conf['event_handlers'][$event])) { |
| 328 | - $eventHandlers = (array)$this->conf['event_handlers'][$event]; |
|
| 328 | + $eventHandlers = (array) $this->conf['event_handlers'][$event]; |
|
| 329 | 329 | foreach ($eventHandlers as $eventHandler) { |
| 330 | 330 | if (!isset(class_implements($eventHandler)[$interface])) { |
| 331 | 331 | throw new \InvalidArgumentException(sprintf( |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | ) |
| 336 | 336 | ); |
| 337 | 337 | } |
| 338 | - $this->callWithCatchException(function () use ($eventHandler, $arguments) { |
|
| 338 | + $this->callWithCatchException(function() use ($eventHandler, $arguments) { |
|
| 339 | 339 | call_user_func_array([(new $eventHandler), 'handle'], $arguments); |
| 340 | 340 | }); |
| 341 | 341 | } |