@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | $config['jobs'][] = CheckGlobalTimerAliveCronJob::class; |
25 | 25 | } |
26 | 26 | |
27 | - $callback = function (Process $process) use ($swoole, $config, $laravelConfig) { |
|
28 | - $pidfile = dirname($swoole->setting['pid_file']) . '/' . $this->timerPidFile; |
|
27 | + $callback = function(Process $process) use ($swoole, $config, $laravelConfig) { |
|
28 | + $pidfile = dirname($swoole->setting['pid_file']).'/'.$this->timerPidFile; |
|
29 | 29 | file_put_contents($pidfile, $process->pid); |
30 | 30 | $this->setProcessTitle(sprintf('%s laravels: timer process', $config['process_prefix'])); |
31 | 31 | $this->initLaravel($laravelConfig, $swoole); |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | |
40 | 40 | $timerIds = $this->registerTimers($config['jobs']); |
41 | 41 | |
42 | - Process::signal(SIGUSR1, function ($signo) use ($config, $timerIds, $process) { |
|
42 | + Process::signal(SIGUSR1, function($signo) use ($config, $timerIds, $process) { |
|
43 | 43 | foreach ($timerIds as $timerId) { |
44 | 44 | if (Timer::exists($timerId)) { |
45 | 45 | Timer::clear($timerId); |
46 | 46 | } |
47 | 47 | } |
48 | - Timer::after($config['max_wait_time'] * 1000, function () use ($process) { |
|
48 | + Timer::after($config['max_wait_time'] * 1000, function() use ($process) { |
|
49 | 49 | $process->exit(0); |
50 | 50 | }); |
51 | 51 | }); |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | if (empty($job->interval())) { |
77 | 77 | throw new \InvalidArgumentException(sprintf('The interval of %s cannot be empty', get_class($job))); |
78 | 78 | } |
79 | - $runJob = function () use ($job) { |
|
80 | - $runCallback = function () use ($job) { |
|
81 | - $this->callWithCatchException(function () use ($job) { |
|
79 | + $runJob = function() use ($job) { |
|
80 | + $runCallback = function() use ($job) { |
|
81 | + $this->callWithCatchException(function() use ($job) { |
|
82 | 82 | if (($job instanceof CheckGlobalTimerAliveCronJob) || $job::isEnable()) { |
83 | 83 | $job->run(); |
84 | 84 | } |
@@ -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() |
@@ -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() |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | $ip = isset($conf['listen_ip']) ? $conf['listen_ip'] : '127.0.0.1'; |
39 | 39 | $port = isset($conf['listen_port']) ? $conf['listen_port'] : 5200; |
40 | - $socketType = isset($conf['socket_type']) ? (int)$conf['socket_type'] : SWOOLE_SOCK_TCP; |
|
40 | + $socketType = isset($conf['socket_type']) ? (int) $conf['socket_type'] : SWOOLE_SOCK_TCP; |
|
41 | 41 | |
42 | 42 | if ($socketType === SWOOLE_SOCK_UNIX_STREAM) { |
43 | 43 | $socketDir = dirname($ip); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | protected function triggerWebSocketEvent($event, array $params) |
95 | 95 | { |
96 | - return $this->callWithCatchException(function () use ($event, $params) { |
|
96 | + return $this->callWithCatchException(function() use ($event, $params) { |
|
97 | 97 | $handler = $this->getWebSocketHandler(); |
98 | 98 | |
99 | 99 | if (method_exists($handler, $event)) { |
@@ -108,19 +108,19 @@ discard block |
||
108 | 108 | protected function bindWebSocketEvents() |
109 | 109 | { |
110 | 110 | if ($this->enableWebSocket) { |
111 | - $this->swoole->on('HandShake', function () { |
|
111 | + $this->swoole->on('HandShake', function() { |
|
112 | 112 | return $this->triggerWebSocketEvent('onHandShake', func_get_args()); |
113 | 113 | }); |
114 | 114 | |
115 | - $this->swoole->on('Open', function () { |
|
115 | + $this->swoole->on('Open', function() { |
|
116 | 116 | $this->triggerWebSocketEvent('onOpen', func_get_args()); |
117 | 117 | }); |
118 | 118 | |
119 | - $this->swoole->on('Message', function () { |
|
119 | + $this->swoole->on('Message', function() { |
|
120 | 120 | $this->triggerWebSocketEvent('onMessage', func_get_args()); |
121 | 121 | }); |
122 | 122 | |
123 | - $this->swoole->on('Close', function (WebSocketServer $server, $fd, $reactorId) { |
|
123 | + $this->swoole->on('Close', function(WebSocketServer $server, $fd, $reactorId) { |
|
124 | 124 | $clientInfo = $server->getClientInfo($fd); |
125 | 125 | if (isset($clientInfo['websocket_status']) && $clientInfo['websocket_status'] === \WEBSOCKET_STATUS_FRAME) { |
126 | 126 | $this->triggerWebSocketEvent('onClose', func_get_args()); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | |
133 | 133 | protected function triggerPortEvent(Port $port, $handlerClass, $event, array $params) |
134 | 134 | { |
135 | - return $this->callWithCatchException(function () use ($port, $handlerClass, $event, $params) { |
|
135 | + return $this->callWithCatchException(function() use ($port, $handlerClass, $event, $params) { |
|
136 | 136 | $handler = $this->getSocketHandler($port, $handlerClass); |
137 | 137 | |
138 | 138 | if (method_exists($handler, $event)) { |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | 'BufferEmpty', |
178 | 178 | ]; |
179 | 179 | foreach ($events as $event) { |
180 | - $port->on($event, function () use ($port, $handlerClass, $event) { |
|
181 | - $this->triggerPortEvent($port, $handlerClass, 'on' . $event, func_get_args()); |
|
180 | + $port->on($event, function() use ($port, $handlerClass, $event) { |
|
181 | + $this->triggerPortEvent($port, $handlerClass, 'on'.$event, func_get_args()); |
|
182 | 182 | }); |
183 | 183 | } |
184 | 184 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | |
228 | 228 | protected function bindSwooleTables() |
229 | 229 | { |
230 | - $tables = isset($this->conf['swoole_tables']) ? (array)$this->conf['swoole_tables'] : []; |
|
230 | + $tables = isset($this->conf['swoole_tables']) ? (array) $this->conf['swoole_tables'] : []; |
|
231 | 231 | foreach ($tables as $name => $table) { |
232 | 232 | $t = new Table($table['size']); |
233 | 233 | foreach ($table['column'] as $column) { |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | $headers = [ |
325 | 325 | 'Upgrade' => 'websocket', |
326 | 326 | 'Connection' => 'Upgrade', |
327 | - 'Sec-WebSocket-Accept' => base64_encode(sha1($secKey . '258EAFA5-E914-47DA-95CA-C5AB0DC85B11', true)), |
|
327 | + 'Sec-WebSocket-Accept' => base64_encode(sha1($secKey.'258EAFA5-E914-47DA-95CA-C5AB0DC85B11', true)), |
|
328 | 328 | 'Sec-WebSocket-Version' => '13', |
329 | 329 | ]; |
330 | 330 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | if (!($listener instanceof Listener)) { |
371 | 371 | throw new \InvalidArgumentException(sprintf('%s must extend the abstract class %s', $listenerClass, Listener::class)); |
372 | 372 | } |
373 | - $this->callWithCatchException(function () use ($listener) { |
|
373 | + $this->callWithCatchException(function() use ($listener) { |
|
374 | 374 | $listener->handle(); |
375 | 375 | }, [], $event->getTries()); |
376 | 376 | } |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | |
380 | 380 | protected function handleTask(Task $task) |
381 | 381 | { |
382 | - return $this->callWithCatchException(function () use ($task) { |
|
382 | + return $this->callWithCatchException(function() use ($task) { |
|
383 | 383 | $task->handle(); |
384 | 384 | return true; |
385 | 385 | }, [], $task->getTries()); |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | protected function fireEvent($event, $interface, array $arguments) |
389 | 389 | { |
390 | 390 | if (isset($this->conf['event_handlers'][$event])) { |
391 | - $eventHandlers = (array)$this->conf['event_handlers'][$event]; |
|
391 | + $eventHandlers = (array) $this->conf['event_handlers'][$event]; |
|
392 | 392 | foreach ($eventHandlers as $eventHandler) { |
393 | 393 | if (!isset(class_implements($eventHandler)[$interface])) { |
394 | 394 | throw new \InvalidArgumentException(sprintf( |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | ) |
399 | 399 | ); |
400 | 400 | } |
401 | - $this->callWithCatchException(function () use ($eventHandler, $arguments) { |
|
401 | + $this->callWithCatchException(function() use ($eventHandler, $arguments) { |
|
402 | 402 | call_user_func_array([(new $eventHandler), 'handle'], $arguments); |
403 | 403 | }); |
404 | 404 | } |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | $parts = parse_url($url); |
32 | 32 | $path = isset($parts['path']) ? $parts['path'] : '/'; |
33 | 33 | if (isset($parts['query'])) { |
34 | - $path .= '?' . $parts['query']; |
|
34 | + $path .= '?'.$parts['query']; |
|
35 | 35 | } |
36 | 36 | if (isset($parts['fragment'])) { |
37 | - $path .= '#' . $parts['fragment']; |
|
37 | + $path .= '#'.$parts['fragment']; |
|
38 | 38 | } |
39 | 39 | $client = new CoroutineClient($parts['host'], isset($parts['port']) ? $parts['port'] : 80, isset($parts['scheme']) && $parts['scheme'] === 'https'); |
40 | 40 | if (isset($options['timeout'])) { |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | continue; |
91 | 91 | } |
92 | 92 | if (isset($headers[$key])) { |
93 | - $headers[$key] = (array)$headers[$key]; |
|
93 | + $headers[$key] = (array) $headers[$key]; |
|
94 | 94 | $headers[$key][] = isset($middle[1]) ? trim($middle[1]) : ''; |
95 | 95 | } else { |
96 | 96 | $headers[$key] = isset($middle[1]) ? trim($middle[1]) : ''; |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $server[$headerServerMapping[$key]] = $value; |
52 | 52 | } else { |
53 | 53 | $key = str_replace('-', '_', $key); |
54 | - $server['http_' . $key] = $value; |
|
54 | + $server['http_'.$key] = $value; |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | $server = array_change_key_case($server, CASE_UPPER); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | && isset($_SERVER['QUERY_STRING']) |
66 | 66 | && $_SERVER['QUERY_STRING'] !== '' |
67 | 67 | ) { |
68 | - $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
68 | + $_SERVER['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | // Fix argv & argc |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | self::autoload($this->conf['root_path']); |
83 | 83 | |
84 | 84 | // Make kernel for Laravel |
85 | - $app = require $this->conf['root_path'] . '/bootstrap/app.php'; |
|
85 | + $app = require $this->conf['root_path'].'/bootstrap/app.php'; |
|
86 | 86 | $kernel = $this->conf['is_lumen'] ? null : $app->make(HttpKernel::class); |
87 | 87 | |
88 | 88 | // Boot |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | { |
103 | 103 | $cfgPaths = [ |
104 | 104 | // Framework default configuration |
105 | - $this->conf['root_path'] . '/vendor/laravel/lumen-framework/config/', |
|
105 | + $this->conf['root_path'].'/vendor/laravel/lumen-framework/config/', |
|
106 | 106 | // App configuration |
107 | - $this->conf['root_path'] . '/config/', |
|
107 | + $this->conf['root_path'].'/config/', |
|
108 | 108 | ]; |
109 | 109 | |
110 | 110 | $keys = []; |
111 | 111 | foreach ($cfgPaths as $cfgPath) { |
112 | - $configs = (array)glob($cfgPath . '*.php'); |
|
112 | + $configs = (array) glob($cfgPath.'*.php'); |
|
113 | 113 | foreach ($configs as $config) { |
114 | 114 | $config = substr(basename($config), 0, -4); |
115 | 115 | $keys[$config] = $config; |
@@ -123,11 +123,11 @@ discard block |
||
123 | 123 | |
124 | 124 | public static function autoload($rootPath) |
125 | 125 | { |
126 | - $autoload = $rootPath . '/bootstrap/autoload.php'; |
|
126 | + $autoload = $rootPath.'/bootstrap/autoload.php'; |
|
127 | 127 | if (file_exists($autoload)) { |
128 | 128 | require_once $autoload; |
129 | 129 | } else { |
130 | - require_once $rootPath . '/vendor/autoload.php'; |
|
130 | + require_once $rootPath.'/vendor/autoload.php'; |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | } |
157 | 157 | |
158 | 158 | // prefer content in response, secondly ob |
159 | - if (!($response instanceof StreamedResponse) && (string)$content === '' && ob_get_length() > 0) { |
|
159 | + if (!($response instanceof StreamedResponse) && (string) $content === '' && ob_get_length() > 0) { |
|
160 | 160 | $response->setContent(ob_get_contents()); |
161 | 161 | } |
162 | 162 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | } |
174 | 174 | $uri = urldecode($uri); |
175 | 175 | |
176 | - $requestFile = $this->conf['static_path'] . $uri; |
|
176 | + $requestFile = $this->conf['static_path'].$uri; |
|
177 | 177 | if (is_file($requestFile)) { |
178 | 178 | return $this->createStaticResponse($requestFile, $request); |
179 | 179 | } |
@@ -189,9 +189,9 @@ discard block |
||
189 | 189 | |
190 | 190 | protected function lookupIndex($folder) |
191 | 191 | { |
192 | - $folder = rtrim($folder, '/') . '/'; |
|
192 | + $folder = rtrim($folder, '/').'/'; |
|
193 | 193 | foreach (self::$staticIndexList as $index) { |
194 | - $tmpFile = $folder . $index; |
|
194 | + $tmpFile = $folder.$index; |
|
195 | 195 | if (is_file($tmpFile)) { |
196 | 196 | return $tmpFile; |
197 | 197 | } |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | |
233 | 233 | public function bindSwoole($swoole) |
234 | 234 | { |
235 | - $this->currentApp->singleton('swoole', function () use ($swoole) { |
|
235 | + $this->currentApp->singleton('swoole', function() use ($swoole) { |
|
236 | 236 | return $swoole; |
237 | 237 | }); |
238 | 238 | } |
@@ -19,17 +19,17 @@ |
||
19 | 19 | return false; |
20 | 20 | } |
21 | 21 | |
22 | - $fileTypes = isset($config['file_types']) ? (array)$config['file_types'] : []; |
|
22 | + $fileTypes = isset($config['file_types']) ? (array) $config['file_types'] : []; |
|
23 | 23 | if (empty($fileTypes)) { |
24 | 24 | $this->warning('No file types to watch by inotify'); |
25 | 25 | return false; |
26 | 26 | } |
27 | 27 | |
28 | - $callback = function () use ($config, $laravelConf) { |
|
28 | + $callback = function() use ($config, $laravelConf) { |
|
29 | 29 | $log = !empty($config['log']); |
30 | 30 | $this->setProcessTitle(sprintf('%s laravels: inotify process', $config['process_prefix'])); |
31 | 31 | $inotify = new Inotify($config['watch_path'], IN_CREATE | IN_DELETE | IN_MODIFY | IN_MOVE, |
32 | - function ($event) use ($log, $laravelConf) { |
|
32 | + function($event) use ($log, $laravelConf) { |
|
33 | 33 | Portal::runLaravelSCommand($laravelConf['root_path'], 'reload'); |
34 | 34 | if ($log) { |
35 | 35 | $action = 'file:'; |