@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | public static function getGlobalTimerCacheKey() |
94 | 94 | { |
95 | - return 'laravels:timer:' . strtolower(self::$globalTimerLockKey); |
|
95 | + return 'laravels:timer:'.strtolower(self::$globalTimerLockKey); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | public static function getGlobalTimerLock() |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | $expire = self::GLOBAL_TIMER_LOCK_SECONDS; |
106 | 106 | $result = $redis->set($key, $value, 'ex', $expire, 'nx'); |
107 | 107 | // Compatible with Predis and PhpRedis |
108 | - return $result === true || ((string)$result === 'OK'); |
|
108 | + return $result === true || ((string) $result === 'OK'); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | protected static function getCurrentInstanceId() |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | { |
118 | 118 | /**@var \Illuminate\Redis\Connections\PhpRedisConnection $redis */ |
119 | 119 | $redis = app('redis'); |
120 | - return (bool)$redis->exists(self::getGlobalTimerCacheKey()); |
|
120 | + return (bool) $redis->exists(self::getGlobalTimerCacheKey()); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | public static function isCurrentTimerAlive() |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | { |
134 | 134 | /**@var \Illuminate\Redis\Connections\PhpRedisConnection $redis */ |
135 | 135 | $redis = app('redis'); |
136 | - return (bool)$redis->expire(self::getGlobalTimerCacheKey(), $expire); |
|
136 | + return (bool) $redis->expire(self::getGlobalTimerCacheKey(), $expire); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | public static function setGlobalTimerLockKey($lockKey) |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | |
144 | 144 | public static function setEnable($enable) |
145 | 145 | { |
146 | - self::$enable = (bool)$enable; |
|
146 | + self::$enable = (bool) $enable; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | public static function isEnable() |
@@ -11,7 +11,7 @@ |
||
11 | 11 | { |
12 | 12 | public function interval() |
13 | 13 | { |
14 | - return (int)(static::GLOBAL_TIMER_LOCK_SECONDS * 0.9) * 1000; |
|
14 | + return (int) (static::GLOBAL_TIMER_LOCK_SECONDS * 0.9) * 1000; |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | public function isImmediate() |
@@ -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 | - 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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |