@@ -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); |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | protected function triggerWebSocketEvent($method, array $params) |
99 | 99 | { |
100 | - $this->callWithCatchException(function () use ($method, $params) { |
|
100 | + $this->callWithCatchException(function() use ($method, $params) { |
|
101 | 101 | $handler = $this->getWebSocketHandler(); |
102 | 102 | |
103 | 103 | if (method_exists($handler, $method)) { |
@@ -112,19 +112,19 @@ discard block |
||
112 | 112 | protected function bindWebSocketEvents() |
113 | 113 | { |
114 | 114 | if ($this->enableWebSocket) { |
115 | - $this->swoole->on('HandShake', function () { |
|
115 | + $this->swoole->on('HandShake', function() { |
|
116 | 116 | $this->triggerWebSocketEvent('onHandShake', func_get_args()); |
117 | 117 | }); |
118 | 118 | |
119 | - $this->swoole->on('Open', function () { |
|
119 | + $this->swoole->on('Open', function() { |
|
120 | 120 | $this->triggerWebSocketEvent('onOpen', func_get_args()); |
121 | 121 | }); |
122 | 122 | |
123 | - $this->swoole->on('Message', function () { |
|
123 | + $this->swoole->on('Message', function() { |
|
124 | 124 | $this->triggerWebSocketEvent('onMessage', func_get_args()); |
125 | 125 | }); |
126 | 126 | |
127 | - $this->swoole->on('Close', function (WebSocketServer $server, $fd, $reactorId) { |
|
127 | + $this->swoole->on('Close', function(WebSocketServer $server, $fd, $reactorId) { |
|
128 | 128 | $clientInfo = $server->getClientInfo($fd); |
129 | 129 | if (isset($clientInfo['websocket_status']) && $clientInfo['websocket_status'] === \WEBSOCKET_STATUS_FRAME) { |
130 | 130 | $this->triggerWebSocketEvent('onClose', func_get_args()); |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | $port->set(empty($socket['settings']) ? [] : $socket['settings']); |
153 | 153 | |
154 | 154 | $handlerClass = $socket['handler']; |
155 | - $eventHandler = function ($method, array $params) use ($port, $handlerClass) { |
|
155 | + $eventHandler = function($method, array $params) use ($port, $handlerClass) { |
|
156 | 156 | $handler = $this->getSocketHandler($port, $handlerClass); |
157 | 157 | if (method_exists($handler, $method)) { |
158 | - $this->callWithCatchException(function () use ($handler, $method, $params) { |
|
158 | + $this->callWithCatchException(function() use ($handler, $method, $params) { |
|
159 | 159 | call_user_func_array([$handler, $method], $params); |
160 | 160 | }); |
161 | 161 | } |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | 'BufferEmpty', |
174 | 174 | ]; |
175 | 175 | foreach ($events as $event) { |
176 | - $port->on($event, function () use ($event, $eventHandler) { |
|
177 | - $eventHandler('on' . $event, func_get_args()); |
|
176 | + $port->on($event, function() use ($event, $eventHandler) { |
|
177 | + $eventHandler('on'.$event, func_get_args()); |
|
178 | 178 | }); |
179 | 179 | } |
180 | 180 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | |
214 | 214 | protected function bindSwooleTables() |
215 | 215 | { |
216 | - $tables = isset($this->conf['swoole_tables']) ? (array)$this->conf['swoole_tables'] : []; |
|
216 | + $tables = isset($this->conf['swoole_tables']) ? (array) $this->conf['swoole_tables'] : []; |
|
217 | 217 | foreach ($tables as $name => $table) { |
218 | 218 | $t = new Table($table['size']); |
219 | 219 | foreach ($table['column'] as $column) { |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | $headers = [ |
311 | 311 | 'Upgrade' => 'websocket', |
312 | 312 | 'Connection' => 'Upgrade', |
313 | - 'Sec-WebSocket-Accept' => base64_encode(sha1($key . '258EAFA5-E914-47DA-95CA-C5AB0DC85B11', true)), |
|
313 | + 'Sec-WebSocket-Accept' => base64_encode(sha1($key.'258EAFA5-E914-47DA-95CA-C5AB0DC85B11', true)), |
|
314 | 314 | 'Sec-WebSocket-Version' => '13', |
315 | 315 | ]; |
316 | 316 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | $response->end(); |
330 | 330 | |
331 | 331 | if (method_exists($this->swoole, 'defer')) { |
332 | - $this->swoole->defer(function () use ($request) { |
|
332 | + $this->swoole->defer(function() use ($request) { |
|
333 | 333 | $this->triggerWebSocketEvent('onOpen', [$this->swoole, $request]); |
334 | 334 | }); |
335 | 335 | } else { |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | if (!($listener instanceof Listener)) { |
365 | 365 | throw new \InvalidArgumentException(sprintf('%s must extend the abstract class %s', $listenerClass, Listener::class)); |
366 | 366 | } |
367 | - $this->callWithCatchException(function () use ($listener) { |
|
367 | + $this->callWithCatchException(function() use ($listener) { |
|
368 | 368 | $listener->handle(); |
369 | 369 | }, [], $event->getTries()); |
370 | 370 | } |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | |
374 | 374 | protected function handleTask(Task $task) |
375 | 375 | { |
376 | - return $this->callWithCatchException(function () use ($task) { |
|
376 | + return $this->callWithCatchException(function() use ($task) { |
|
377 | 377 | $task->handle(); |
378 | 378 | return true; |
379 | 379 | }, [], $task->getTries()); |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | protected function fireEvent($event, $interface, array $arguments) |
383 | 383 | { |
384 | 384 | if (isset($this->conf['event_handlers'][$event])) { |
385 | - $eventHandlers = (array)$this->conf['event_handlers'][$event]; |
|
385 | + $eventHandlers = (array) $this->conf['event_handlers'][$event]; |
|
386 | 386 | foreach ($eventHandlers as $eventHandler) { |
387 | 387 | if (!isset(class_implements($eventHandler)[$interface])) { |
388 | 388 | throw new \InvalidArgumentException(sprintf( |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | ) |
393 | 393 | ); |
394 | 394 | } |
395 | - $this->callWithCatchException(function () use ($eventHandler, $arguments) { |
|
395 | + $this->callWithCatchException(function() use ($eventHandler, $arguments) { |
|
396 | 396 | call_user_func_array([(new $eventHandler), 'handle'], $arguments); |
397 | 397 | }); |
398 | 398 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | 'class' => self::class, |
21 | 21 | 'redirect' => false, |
22 | 22 | 'pipe' => 0, |
23 | - 'enable' => (bool)getenv('ENABLE_APOLLO'), |
|
23 | + 'enable' => (bool) getenv('ENABLE_APOLLO'), |
|
24 | 24 | ], |
25 | 25 | ]; |
26 | 26 | } |
@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | { |
30 | 30 | $filename = base_path('.env'); |
31 | 31 | if (isset($_ENV['APP_ENV'])) { |
32 | - $filename .= '.' . $_ENV['APP_ENV']; |
|
32 | + $filename .= '.'.$_ENV['APP_ENV']; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | self::$apollo = Client::createFromEnv(); |
36 | - self::$apollo->startWatchNotification(function (array $notifications) use ($process, $filename) { |
|
36 | + self::$apollo->startWatchNotification(function(array $notifications) use ($process, $filename) { |
|
37 | 37 | $configs = self::$apollo->pullAllAndSave($filename); |
38 | 38 | app('log')->info('[ApolloProcess] Pull all configurations', $configs); |
39 | 39 | $process->exec(PHP_BINARY, [base_path('bin/laravels'), 'reload']); |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | public function handle() |
23 | 23 | { |
24 | - $action = (string)$this->argument('action'); |
|
24 | + $action = (string) $this->argument('action'); |
|
25 | 25 | switch ($action) { |
26 | 26 | case 'publish': |
27 | 27 | $this->publish(); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | { |
54 | 54 | // Load configuration laravel.php manually for Lumen |
55 | 55 | $basePath = config('laravels.laravel_base_path') ?: base_path(); |
56 | - if ($this->isLumen() && file_exists($basePath . '/config/laravels.php')) { |
|
56 | + if ($this->isLumen() && file_exists($basePath.'/config/laravels.php')) { |
|
57 | 57 | $this->getLaravel()->configure('laravels'); |
58 | 58 | } |
59 | 59 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $laravelSVersion, |
111 | 111 | ], |
112 | 112 | [ |
113 | - $this->getApplication()->getName() . ' [<info>' . env('APP_ENV', config('app.env')) . '</info>]', |
|
113 | + $this->getApplication()->getName().' [<info>'.env('APP_ENV', config('app.env')).'</info>]', |
|
114 | 114 | $this->getApplication()->getVersion(), |
115 | 115 | ], |
116 | 116 | ]); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | { |
121 | 121 | $this->comment('>>> Protocols'); |
122 | 122 | |
123 | - $config = unserialize((string)file_get_contents($this->getConfPath())); |
|
123 | + $config = unserialize((string) file_get_contents($this->getConfPath())); |
|
124 | 124 | $ssl = isset($config['server']['swoole']['ssl_key_file'], $config['server']['swoole']['ssl_cert_file']); |
125 | 125 | $socketType = isset($config['server']['socket_type']) ? $config['server']['socket_type'] : SWOOLE_SOCK_TCP; |
126 | 126 | if (in_array($socketType, [SWOOLE_SOCK_UNIX_DGRAM, SWOOLE_SOCK_UNIX_STREAM])) { |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | continue; |
161 | 161 | } |
162 | 162 | |
163 | - $name = 'Port#' . $key . ' '; |
|
163 | + $name = 'Port#'.$key.' '; |
|
164 | 164 | $name .= isset($socketTypeNames[$socket['type']]) ? $socketTypeNames[$socket['type']] : 'Unknown socket'; |
165 | 165 | $tableRows [] = [ |
166 | 166 | $name, |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | $laravelConf = [ |
189 | 189 | 'root_path' => $svrConf['laravel_base_path'], |
190 | 190 | 'static_path' => $svrConf['swoole']['document_root'], |
191 | - 'cleaners' => array_unique((array)Arr::get($svrConf, 'cleaners', [])), |
|
192 | - 'register_providers' => array_unique((array)Arr::get($svrConf, 'register_providers', [])), |
|
191 | + 'cleaners' => array_unique((array) Arr::get($svrConf, 'cleaners', [])), |
|
192 | + 'register_providers' => array_unique((array) Arr::get($svrConf, 'register_providers', [])), |
|
193 | 193 | 'destroy_controllers' => Arr::get($svrConf, 'destroy_controllers', []), |
194 | 194 | 'is_lumen' => $this->isLumen(), |
195 | 195 | '_SERVER' => $_SERVER, |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $svrConf['ignore_check_pid'] = false; |
223 | 223 | } |
224 | 224 | if (empty($svrConf['swoole']['document_root'])) { |
225 | - $svrConf['swoole']['document_root'] = $svrConf['laravel_base_path'] . '/public'; |
|
225 | + $svrConf['swoole']['document_root'] = $svrConf['laravel_base_path'].'/public'; |
|
226 | 226 | } |
227 | 227 | if ($this->option('daemonize')) { |
228 | 228 | $svrConf['swoole']['daemonize'] = true; |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | } |
238 | 238 | |
239 | 239 | // Set X-Version |
240 | - $xVersion = (string)$this->option('x-version'); |
|
240 | + $xVersion = (string) $this->option('x-version'); |
|
241 | 241 | if ($xVersion !== '') { |
242 | 242 | $_SERVER['X_VERSION'] = $_ENV['X_VERSION'] = $xVersion; |
243 | 243 | } |
@@ -264,34 +264,34 @@ discard block |
||
264 | 264 | public function publish() |
265 | 265 | { |
266 | 266 | $basePath = config('laravels.laravel_base_path') ?: base_path(); |
267 | - $configPath = $basePath . '/config/laravels.php'; |
|
267 | + $configPath = $basePath.'/config/laravels.php'; |
|
268 | 268 | $todoList = [ |
269 | 269 | [ |
270 | - 'from' => realpath(__DIR__ . '/../../config/laravels.php'), |
|
270 | + 'from' => realpath(__DIR__.'/../../config/laravels.php'), |
|
271 | 271 | 'to' => $configPath, |
272 | 272 | 'mode' => 0644, |
273 | 273 | ], |
274 | 274 | [ |
275 | - 'from' => realpath(__DIR__ . '/../../bin/laravels'), |
|
276 | - 'to' => $basePath . '/bin/laravels', |
|
275 | + 'from' => realpath(__DIR__.'/../../bin/laravels'), |
|
276 | + 'to' => $basePath.'/bin/laravels', |
|
277 | 277 | 'mode' => 0755, |
278 | 278 | 'link' => true, |
279 | 279 | ], |
280 | 280 | [ |
281 | - 'from' => realpath(__DIR__ . '/../../bin/fswatch'), |
|
282 | - 'to' => $basePath . '/bin/fswatch', |
|
281 | + 'from' => realpath(__DIR__.'/../../bin/fswatch'), |
|
282 | + 'to' => $basePath.'/bin/fswatch', |
|
283 | 283 | 'mode' => 0755, |
284 | 284 | 'link' => true, |
285 | 285 | ], |
286 | 286 | [ |
287 | - 'from' => realpath(__DIR__ . '/../../bin/inotify'), |
|
288 | - 'to' => $basePath . '/bin/inotify', |
|
287 | + 'from' => realpath(__DIR__.'/../../bin/inotify'), |
|
288 | + 'to' => $basePath.'/bin/inotify', |
|
289 | 289 | 'mode' => 0755, |
290 | 290 | 'link' => true, |
291 | 291 | ], |
292 | 292 | ]; |
293 | 293 | if (file_exists($configPath)) { |
294 | - $choice = $this->anticipate($configPath . ' already exists, do you want to override it ? Y/N', |
|
294 | + $choice = $this->anticipate($configPath.' already exists, do you want to override it ? Y/N', |
|
295 | 295 | ['Y', 'N'], |
296 | 296 | 'N' |
297 | 297 | ); |