@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | // enable sandbox |
89 | 89 | $sandbox->enable(); |
90 | 90 | // call customized handshake handler |
91 | - if ($response && ! $this->app->make($handshakeHandler)->handle($swooleRequest, $response)) { |
|
91 | + if ($response && !$this->app->make($handshakeHandler)->handle($swooleRequest, $response)) { |
|
92 | 92 | return; |
93 | 93 | } |
94 | 94 | // check if socket.io connection established |
95 | - if (! $this->websocketHandler->onOpen($swooleRequest->fd, $illuminateRequest)) { |
|
95 | + if (!$this->websocketHandler->onOpen($swooleRequest->fd, $illuminateRequest)) { |
|
96 | 96 | return; |
97 | 97 | } |
98 | 98 | // trigger 'connect' websocket event |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function onClose($server, $fd, $reactorId) |
158 | 158 | { |
159 | - if (! $this->isServerWebsocket($fd) || ! $server instanceof WebsocketServer) { |
|
159 | + if (!$this->isServerWebsocket($fd) || !$server instanceof WebsocketServer) { |
|
160 | 160 | return; |
161 | 161 | } |
162 | 162 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | protected function isWebsocketPushPacket($packet) |
188 | 188 | { |
189 | - if (! is_array($packet)) { |
|
189 | + if (!is_array($packet)) { |
|
190 | 190 | return false; |
191 | 191 | } |
192 | 192 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $config = $this->container->make('config'); |
242 | 242 | $parser = $config->get('swoole_websocket.parser'); |
243 | 243 | |
244 | - if (! $this->isServerWebsocket = $config->get('swoole_http.websocket.enabled')) { |
|
244 | + if (!$this->isServerWebsocket = $config->get('swoole_http.websocket.enabled')) { |
|
245 | 245 | return; |
246 | 246 | } |
247 | 247 | |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | { |
280 | 280 | $handlerClass = $this->container->make('config')->get('swoole_websocket.handler'); |
281 | 281 | |
282 | - if (! $handlerClass) { |
|
282 | + if (!$handlerClass) { |
|
283 | 283 | throw new WebsocketNotSetInConfigException; |
284 | 284 | } |
285 | 285 | |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | */ |
341 | 341 | protected function bindRoom(): void |
342 | 342 | { |
343 | - $this->app->singleton(RoomContract::class, function () { |
|
343 | + $this->app->singleton(RoomContract::class, function() { |
|
344 | 344 | return $this->websocketRoom; |
345 | 345 | }); |
346 | 346 | |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | */ |
353 | 353 | protected function bindWebsocket() |
354 | 354 | { |
355 | - $this->app->singleton(Websocket::class, function (Container $app) { |
|
355 | + $this->app->singleton(Websocket::class, function(Container $app) { |
|
356 | 356 | return new Websocket($app->make(RoomContract::class), new Pipeline($app)); |
357 | 357 | }); |
358 | 358 | |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | $routePath = $this->container->make('config') |
368 | 368 | ->get('swoole_websocket.route_file'); |
369 | 369 | |
370 | - if (! file_exists($routePath)) { |
|
370 | + if (!file_exists($routePath)) { |
|
371 | 371 | $routePath = __DIR__ . '/../../routes/websocket.php'; |
372 | 372 | } |
373 | 373 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | */ |
384 | 384 | public function isWebsocketPushPayload($payload): bool |
385 | 385 | { |
386 | - if (! is_array($payload)) { |
|
386 | + if (!is_array($payload)) { |
|
387 | 387 | return false; |
388 | 388 | } |
389 | 389 |
@@ -44,7 +44,7 @@ |
||
44 | 44 | try { |
45 | 45 | $this->auth->setRequest($request); |
46 | 46 | if ($user = $this->auth->authenticate()) { |
47 | - $request->setUserResolver(function () use ($user) { |
|
47 | + $request->setUserResolver(function() use ($user) { |
|
48 | 48 | return $user; |
49 | 49 | }); |
50 | 50 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $this->createTables(); |
116 | 116 | $this->prepareWebsocket(); |
117 | 117 | |
118 | - if (! $this->container->make(Server::class)->taskworker) { |
|
118 | + if (!$this->container->make(Server::class)->taskworker) { |
|
119 | 119 | $this->setSwooleServerListeners(); |
120 | 120 | } |
121 | 121 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $server = $this->container->make(Server::class); |
129 | 129 | foreach ($this->events as $event) { |
130 | 130 | $listener = Str::camel("on_$event"); |
131 | - $callback = method_exists($this, $listener) ? [$this, $listener] : function () use ($event) { |
|
131 | + $callback = method_exists($this, $listener) ? [$this, $listener] : function() use ($event) { |
|
132 | 132 | $this->container->make('events')->dispatch("swoole.$event", func_get_args()); |
133 | 133 | }; |
134 | 134 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | */ |
323 | 323 | protected function bindSandbox() |
324 | 324 | { |
325 | - $this->app->singleton(Sandbox::class, function ($app) { |
|
325 | + $this->app->singleton(Sandbox::class, function($app) { |
|
326 | 326 | return new Sandbox($app, $this->framework); |
327 | 327 | }); |
328 | 328 | |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | */ |
411 | 411 | protected function normalizeException(Throwable $e) |
412 | 412 | { |
413 | - if (! $e instanceof Exception) { |
|
413 | + if (!$e instanceof Exception) { |
|
414 | 414 | $e = new FatalThrowableError($e); |
415 | 415 | } |
416 | 416 |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | protected function startSession(Request $request) |
60 | 60 | { |
61 | - return tap($this->getSession($request), function (Session $session) use ($request) { |
|
61 | + return tap($this->getSession($request), function(Session $session) use ($request) { |
|
62 | 62 | $session->setRequestOnHandler($request); |
63 | 63 | |
64 | 64 | $session->start(); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function getSession(Request $request) |
76 | 76 | { |
77 | - return tap($this->manager->driver(), function (Session $session) use ($request) { |
|
77 | + return tap($this->manager->driver(), function(Session $session) use ($request) { |
|
78 | 78 | $session->setId($request->cookies->get($session->getName())); |
79 | 79 | }); |
80 | 80 | } |
@@ -86,6 +86,6 @@ discard block |
||
86 | 86 | */ |
87 | 87 | protected function sessionConfigured() |
88 | 88 | { |
89 | - return ! is_null($this->manager->getSessionConfig()['driver'] ?? null); |
|
89 | + return !is_null($this->manager->getSessionConfig()['driver'] ?? null); |
|
90 | 90 | } |
91 | 91 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | /** |
4 | 4 | * This is only for `function not exists` in config/swoole_http.php. |
5 | 5 | */ |
6 | -if (! function_exists('swoole_cpu_num')) { |
|
6 | +if (!function_exists('swoole_cpu_num')) { |
|
7 | 7 | function swoole_cpu_num(): int |
8 | 8 | { |
9 | 9 | return 1; |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | /** |
14 | 14 | * This is only for `function not exists` in config/swoole_http.php. |
15 | 15 | */ |
16 | -if (! defined('SWOOLE_SOCK_TCP')) { |
|
16 | +if (!defined('SWOOLE_SOCK_TCP')) { |
|
17 | 17 | define('SWOOLE_SOCK_TCP', 1); |
18 | 18 | } |
19 | 19 | |
20 | -if (! defined('SWOOLE_PROCESS')) { |
|
20 | +if (!defined('SWOOLE_PROCESS')) { |
|
21 | 21 | define('SWOOLE_PROCESS', 2); |
22 | 22 | } |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | |
174 | 174 | static::$server = new $server($host, $port, $processType, $socketType); |
175 | 175 | |
176 | - if(intval($ssl_port) > 0) |
|
177 | - static::$server->listen($host, $ssl_port, SWOOLE_SOCK_TCP | SWOOLE_SSL ); |
|
176 | + if (intval($ssl_port) > 0) |
|
177 | + static::$server->listen($host, $ssl_port, SWOOLE_SOCK_TCP | SWOOLE_SSL); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $options = $config->get('swoole_http.server.options'); |
187 | 187 | |
188 | 188 | // only enable task worker in websocket mode and for queue driver |
189 | - if ($config->get('queue.default') !== 'swoole' && ! $this->isWebsocket) { |
|
189 | + if ($config->get('queue.default') !== 'swoole' && !$this->isWebsocket) { |
|
190 | 190 | unset($options['task_worker_num']); |
191 | 191 | } |
192 | 192 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | */ |
201 | 201 | protected function registerServer() |
202 | 202 | { |
203 | - $this->app->singleton(Server::class, function () { |
|
203 | + $this->app->singleton(Server::class, function() { |
|
204 | 204 | if (is_null(static::$server)) { |
205 | 205 | $this->createSwooleServer(); |
206 | 206 | $this->configureSwooleServer(); |
@@ -216,8 +216,8 @@ discard block |
||
216 | 216 | */ |
217 | 217 | protected function registerDatabaseDriver() |
218 | 218 | { |
219 | - $this->app->extend(DatabaseManager::class, function (DatabaseManager $db) { |
|
220 | - $db->extend('mysql-coroutine', function ($config, $name) { |
|
219 | + $this->app->extend(DatabaseManager::class, function(DatabaseManager $db) { |
|
220 | + $db->extend('mysql-coroutine', function($config, $name) { |
|
221 | 221 | $config['name'] = $name; |
222 | 222 | |
223 | 223 | $connection = new MySqlConnection( |
@@ -260,8 +260,8 @@ discard block |
||
260 | 260 | */ |
261 | 261 | protected function registerSwooleQueueDriver() |
262 | 262 | { |
263 | - $this->app->afterResolving('queue', function (QueueManager $manager) { |
|
264 | - $manager->addConnector('swoole', function () { |
|
263 | + $this->app->afterResolving('queue', function(QueueManager $manager) { |
|
264 | + $manager->addConnector('swoole', function() { |
|
265 | 265 | return new SwooleTaskConnector($this->app->make(Server::class)); |
266 | 266 | }); |
267 | 267 | }); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | $this->info('Starting swoole http server...'); |
110 | 110 | $this->info("Swoole http server started: <http://{$host}:{$port}>"); |
111 | - if(intval($ssl_port) > 0) |
|
111 | + if (intval($ssl_port) > 0) |
|
112 | 112 | $this->info("Swoole https server started: <https://{$host}:{$ssl_port}>"); |
113 | 113 | |
114 | 114 | if ($this->isDaemon()) { |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | */ |
138 | 138 | protected function stop() |
139 | 139 | { |
140 | - if (! $this->isRunning()) { |
|
140 | + if (!$this->isRunning()) { |
|
141 | 141 | $this->error("Failed! There is no swoole_http_server process running."); |
142 | 142 | |
143 | 143 | return; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | protected function reload() |
179 | 179 | { |
180 | - if (! $this->isRunning()) { |
|
180 | + if (!$this->isRunning()) { |
|
181 | 181 | $this->error("Failed! There is no swoole_http_server process running."); |
182 | 182 | |
183 | 183 | return; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | |
186 | 186 | $this->info('Reloading swoole_http_server...'); |
187 | 187 | |
188 | - if (! $this->killProcess(SIGUSR1)) { |
|
188 | + if (!$this->killProcess(SIGUSR1)) { |
|
189 | 189 | $this->error('> failure'); |
190 | 190 | |
191 | 191 | return; |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | { |
247 | 247 | $this->action = $this->argument('action'); |
248 | 248 | |
249 | - if (! in_array($this->action, ['start', 'stop', 'restart', 'reload', 'infos'], true)) { |
|
249 | + if (!in_array($this->action, ['start', 'stop', 'restart', 'reload', 'infos'], true)) { |
|
250 | 250 | $this->error( |
251 | 251 | "Invalid argument '{$this->action}'. Expected 'start', 'stop', 'restart', 'reload' or 'infos'." |
252 | 252 | ); |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | $filter = Arr::get($this->config, 'hot_reload.filter'); |
268 | 268 | $log = Arr::get($this->config, 'hot_reload.log'); |
269 | 269 | |
270 | - $cb = function (FSEvent $event) use ($server, $log) { |
|
270 | + $cb = function(FSEvent $event) use ($server, $log) { |
|
271 | 271 | $log ? $this->info(FSOutput::format($event)) : null; |
272 | 272 | $server->reload(); |
273 | 273 | }; |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | { |
287 | 287 | $pids = $this->laravel->make(PidManager::class)->read(); |
288 | 288 | |
289 | - if (! count($pids)) { |
|
289 | + if (!count($pids)) { |
|
290 | 290 | return false; |
291 | 291 | } |
292 | 292 | |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | $start = time(); |
322 | 322 | |
323 | 323 | do { |
324 | - if (! $this->isRunning()) { |
|
324 | + if (!$this->isRunning()) { |
|
325 | 325 | break; |
326 | 326 | } |
327 | 327 | |
@@ -351,13 +351,13 @@ discard block |
||
351 | 351 | exit(1); |
352 | 352 | } |
353 | 353 | |
354 | - if (! extension_loaded('swoole')) { |
|
354 | + if (!extension_loaded('swoole')) { |
|
355 | 355 | $this->error('Can\'t detect Swoole extension installed.'); |
356 | 356 | |
357 | 357 | exit(1); |
358 | 358 | } |
359 | 359 | |
360 | - if (! version_compare(swoole_version(), '4.3.1', 'ge')) { |
|
360 | + if (!version_compare(swoole_version(), '4.3.1', 'ge')) { |
|
361 | 361 | $this->error('Your Swoole version must be higher than `4.3.1`.'); |
362 | 362 | |
363 | 363 | exit(1); |
@@ -369,15 +369,15 @@ discard block |
||
369 | 369 | */ |
370 | 370 | protected function registerAccessLog() |
371 | 371 | { |
372 | - $this->laravel->singleton(OutputStyle::class, function () { |
|
372 | + $this->laravel->singleton(OutputStyle::class, function() { |
|
373 | 373 | return new OutputStyle($this->input, $this->output); |
374 | 374 | }); |
375 | 375 | |
376 | - $this->laravel->singleton(AccessOutput::class, function () { |
|
376 | + $this->laravel->singleton(AccessOutput::class, function() { |
|
377 | 377 | return new AccessOutput(new ConsoleOutput); |
378 | 378 | }); |
379 | 379 | |
380 | - $this->laravel->singleton(AccessLog::class, function (Container $container) { |
|
380 | + $this->laravel->singleton(AccessLog::class, function(Container $container) { |
|
381 | 381 | return new AccessLog($container->make(AccessOutput::class)); |
382 | 382 | }); |
383 | 383 | } |