@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | public function addFileType($type) |
29 | 29 | { |
30 | - $type = '.' . trim($type, '.'); |
|
30 | + $type = '.'.trim($type, '.'); |
|
31 | 31 | $this->fileTypes[$type] = true; |
32 | 32 | } |
33 | 33 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | public function isExcluded($path) |
55 | 55 | { |
56 | 56 | foreach ($this->excludedDirs as $excludedDir) { |
57 | - if ($excludedDir === $path || strpos($path, $excludedDir . '/') === 0) { |
|
57 | + if ($excludedDir === $path || strpos($path, $excludedDir.'/') === 0) { |
|
58 | 58 | return true; |
59 | 59 | } |
60 | 60 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | if ($file === '.' || $file === '..' || $this->isExcluded($file)) { |
89 | 89 | continue; |
90 | 90 | } |
91 | - $file = $path . DIRECTORY_SEPARATOR . $file; |
|
91 | + $file = $path.DIRECTORY_SEPARATOR.$file; |
|
92 | 92 | if (is_dir($file)) { |
93 | 93 | $this->_watch($file); |
94 | 94 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | public function start() |
124 | 124 | { |
125 | - Event::add($this->fd, function ($fp) { |
|
125 | + Event::add($this->fd, function($fp) { |
|
126 | 126 | $events = inotify_read($fp); |
127 | 127 | foreach ($events as $event) { |
128 | 128 | if ($event['mask'] == IN_IGNORED) { |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | continue; |
139 | 139 | } |
140 | 140 | |
141 | - Timer::after(100, function () use ($event) { |
|
141 | + Timer::after(100, function() use ($event) { |
|
142 | 142 | call_user_func_array($this->watchHandler, [$event]); |
143 | 143 | $this->doing = false; |
144 | 144 | }); |
@@ -35,7 +35,7 @@ |
||
35 | 35 | } |
36 | 36 | |
37 | 37 | if ($len > $this->chunkLimit) { |
38 | - for ($offset = 0, $limit = (int)(0.6 * $this->chunkLimit); $offset < $len; $offset += $limit) { |
|
38 | + for ($offset = 0, $limit = (int) (0.6 * $this->chunkLimit); $offset < $len; $offset += $limit) { |
|
39 | 39 | $chunk = substr($content, $offset, $limit); |
40 | 40 | $this->swooleResponse->write($chunk); |
41 | 41 | } |
@@ -47,7 +47,7 @@ |
||
47 | 47 | if ($deleteFile) { |
48 | 48 | $fp = fopen($path, 'rb'); |
49 | 49 | |
50 | - for ($offset = 0, $limit = (int)(0.99 * $this->chunkLimit); $offset < $size; $offset += $limit) { |
|
50 | + for ($offset = 0, $limit = (int) (0.99 * $this->chunkLimit); $offset < $size; $offset += $limit) { |
|
51 | 51 | fseek($fp, $offset, SEEK_SET); |
52 | 52 | $chunk = fread($fp, $limit); |
53 | 53 | $this->swooleResponse->write($chunk); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $server[$headerServerMapping[$key]] = $value; |
51 | 51 | } else { |
52 | 52 | $key = str_replace('-', '_', $key); |
53 | - $server['http_' . $key] = $value; |
|
53 | + $server['http_'.$key] = $value; |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | $server = array_change_key_case($server, CASE_UPPER); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | && isset($_SERVER['QUERY_STRING']) |
65 | 65 | && strlen($_SERVER['QUERY_STRING']) > 0 |
66 | 66 | ) { |
67 | - $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
67 | + $_SERVER['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | // Fix argv & argc |
@@ -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 | $reloadCmd = trim(sprintf('%s -c "%s" %s/bin/laravels reload', PHP_BINARY, php_ini_loaded_file(), $laravelConf['root_path'])); |
34 | 34 | Portal::runCommand($reloadCmd); |
35 | 35 | if ($log) { |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | if ($delay < 0) { |
29 | 29 | throw new \InvalidArgumentException('The delay must be greater than or equal to 0'); |
30 | 30 | } |
31 | - $this->delay = (int)$delay; |
|
31 | + $this->delay = (int) $delay; |
|
32 | 32 | return $this; |
33 | 33 | } |
34 | 34 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | if ($tries < 1) { |
52 | 52 | throw new \InvalidArgumentException('The number of attempts must be greater than or equal to 1'); |
53 | 53 | } |
54 | - $this->tries = (int)$tries; |
|
54 | + $this->tries = (int) $tries; |
|
55 | 55 | return $this; |
56 | 56 | } |
57 | 57 | |
@@ -71,19 +71,19 @@ discard block |
||
71 | 71 | */ |
72 | 72 | protected function task($task) |
73 | 73 | { |
74 | - $deliver = function () use ($task) { |
|
74 | + $deliver = function() use ($task) { |
|
75 | 75 | /**@var \Swoole\Http\Server $swoole */ |
76 | 76 | $swoole = app('swoole'); |
77 | 77 | // The worker_id of timer process is -1 |
78 | 78 | if ($swoole->worker_id === -1 || $swoole->taskworker) { |
79 | - $taskWorkerNum = isset($swoole->setting['task_worker_num']) ? (int)$swoole->setting['task_worker_num'] : 0; |
|
79 | + $taskWorkerNum = isset($swoole->setting['task_worker_num']) ? (int) $swoole->setting['task_worker_num'] : 0; |
|
80 | 80 | if ($taskWorkerNum < 2) { |
81 | 81 | throw new \InvalidArgumentException('LaravelS: async task needs to set task_worker_num >= 2'); |
82 | 82 | } |
83 | 83 | $workerNum = isset($swoole->setting['worker_num']) ? $swoole->setting['worker_num'] : 0; |
84 | 84 | $totalNum = $workerNum + $taskWorkerNum; |
85 | 85 | |
86 | - $getAvailableId = function ($startId, $endId, $excludeId) { |
|
86 | + $getAvailableId = function($startId, $endId, $excludeId) { |
|
87 | 87 | $ids = range($startId, $endId); |
88 | 88 | $ids = array_flip($ids); |
89 | 89 | unset($ids[$excludeId]); |
@@ -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()); |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | ) |
335 | 335 | ); |
336 | 336 | } |
337 | - $this->callWithCatchException(function () use ($eventHandler, $arguments) { |
|
337 | + $this->callWithCatchException(function() use ($eventHandler, $arguments) { |
|
338 | 338 | call_user_func_array([(new $eventHandler), 'handle'], $arguments); |
339 | 339 | }); |
340 | 340 | } |
@@ -76,13 +76,13 @@ |
||
76 | 76 | parent::bindWebSocketEvent(); |
77 | 77 | |
78 | 78 | if ($this->enableWebSocket) { |
79 | - $eventHandler = function ($method, array $params) { |
|
80 | - $this->callWithCatchException(function () use ($method, $params) { |
|
79 | + $eventHandler = function($method, array $params) { |
|
80 | + $this->callWithCatchException(function() use ($method, $params) { |
|
81 | 81 | call_user_func_array([$this->getWebSocketHandler(), $method], $params); |
82 | 82 | }); |
83 | 83 | }; |
84 | 84 | |
85 | - $this->swoole->on('Open', function (WebSocketServer $server, SwooleRequest $request) use ($eventHandler) { |
|
85 | + $this->swoole->on('Open', function(WebSocketServer $server, SwooleRequest $request) use ($eventHandler) { |
|
86 | 86 | // Start Laravel's lifetime, then support session ...middleware. |
87 | 87 | $laravelRequest = $this->convertRequest($this->laravel, $request); |
88 | 88 | $this->laravel->bindRequest($laravelRequest); |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | // Add backup cron job. |
20 | 20 | $config['jobs'][] = BackupCronJob::class; |
21 | 21 | |
22 | - $callback = function (Process $process) use ($swoole, $config, $laravelConfig) { |
|
23 | - $pidfile = dirname($swoole->setting['pid_file']) . '/' . $this->timerPidFile; |
|
22 | + $callback = function(Process $process) use ($swoole, $config, $laravelConfig) { |
|
23 | + $pidfile = dirname($swoole->setting['pid_file']).'/'.$this->timerPidFile; |
|
24 | 24 | file_put_contents($pidfile, $process->pid); |
25 | 25 | $this->setProcessTitle(sprintf('%s laravels: timer process', $config['process_prefix'])); |
26 | 26 | $this->initLaravel($laravelConfig, $swoole); |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | if (empty($job->interval())) { |
43 | 43 | throw new \InvalidArgumentException(sprintf('The interval of %s cannot be empty', get_class($job))); |
44 | 44 | } |
45 | - $runJob = function () use ($job) { |
|
46 | - $runCallback = function () use ($job) { |
|
47 | - $this->callWithCatchException(function () use ($job) { |
|
45 | + $runJob = function() use ($job) { |
|
46 | + $runCallback = function() use ($job) { |
|
47 | + $this->callWithCatchException(function() use ($job) { |
|
48 | 48 | $job->run(); |
49 | 49 | }); |
50 | 50 | }; |
@@ -59,13 +59,13 @@ discard block |
||
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
62 | - Process::signal(SIGUSR1, function ($signo) use ($config, $timerIds, $process) { |
|
62 | + Process::signal(SIGUSR1, function($signo) use ($config, $timerIds, $process) { |
|
63 | 63 | foreach ($timerIds as $timerId) { |
64 | 64 | if (Timer::exists($timerId)) { |
65 | 65 | Timer::clear($timerId); |
66 | 66 | } |
67 | 67 | } |
68 | - Timer::after($config['max_wait_time'] * 1000, function () use ($process) { |
|
68 | + Timer::after($config['max_wait_time'] * 1000, function() use ($process) { |
|
69 | 69 | $process->exit(0); |
70 | 70 | }); |
71 | 71 | }); |