@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | protected function registerManager() |
| 19 | 19 | { |
| 20 | - $this->app->singleton(Manager::class, function ($app) { |
|
| 20 | + $this->app->singleton(Manager::class, function($app) { |
|
| 21 | 21 | return new Manager($app, 'lumen'); |
| 22 | 22 | }); |
| 23 | 23 | |
@@ -35,11 +35,11 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | // router only exists after lumen 5.5 |
| 37 | 37 | if (property_exists($app, 'router')) { |
| 38 | - $app->router->group(['namespace' => 'SwooleTW\Http\Controllers'], function ($app) { |
|
| 38 | + $app->router->group(['namespace' => 'SwooleTW\Http\Controllers'], function($app) { |
|
| 39 | 39 | require __DIR__ . '/../routes/lumen_routes.php'; |
| 40 | 40 | }); |
| 41 | 41 | } else { |
| 42 | - $app->group(['namespace' => 'App\Http\Controllers'], function ($app) { |
|
| 42 | + $app->group(['namespace' => 'App\Http\Controllers'], function($app) { |
|
| 43 | 43 | require __DIR__ . '/../routes/lumen_routes.php'; |
| 44 | 44 | }); |
| 45 | 45 | } |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require __DIR__.'/vendor/autoload.php'; |
|
| 3 | +require __DIR__ . '/vendor/autoload.php'; |
|
| 4 | 4 | |
| 5 | 5 | use SwooleTW\Http\Helpers\FW; |
| 6 | 6 | use SwooleTW\Http\Task\QueueFactory; |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | public function shouldBroadcast(): bool |
| 211 | 211 | { |
| 212 | - return $this->broadcast && empty($this->descriptors) && ! $this->assigned; |
|
| 212 | + return $this->broadcast && empty($this->descriptors) && !$this->assigned; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | */ |
| 234 | 234 | protected function getWebsocketConnections(): array |
| 235 | 235 | { |
| 236 | - return array_filter(iterator_to_array($this->server->connections), function ($fd) { |
|
| 236 | + return array_filter(iterator_to_array($this->server->connections), function($fd) { |
|
| 237 | 237 | return $this->isServerWebsocket($fd); |
| 238 | 238 | }); |
| 239 | 239 | } |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | */ |
| 246 | 246 | public function shouldPushToDescriptor(int $fd): bool |
| 247 | 247 | { |
| 248 | - if (! $this->server->exist($fd)) { |
|
| 248 | + if (!$this->server->exist($fd)) { |
|
| 249 | 249 | return false; |
| 250 | 250 | } |
| 251 | 251 | |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | public function push($payload): void |
| 263 | 263 | { |
| 264 | 264 | // attach sender if not broadcast |
| 265 | - if (! $this->broadcast && $this->sender && ! $this->hasDescriptor($this->sender)) { |
|
| 265 | + if (!$this->broadcast && $this->sender && !$this->hasDescriptor($this->sender)) { |
|
| 266 | 266 | $this->addDescriptor($this->sender); |
| 267 | 267 | } |
| 268 | 268 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | // enable sandbox |
| 67 | 67 | $sandbox->enable(); |
| 68 | 68 | // check if socket.io connection established |
| 69 | - if (! $this->websocketHandler->onOpen($swooleRequest->fd, $illuminateRequest)) { |
|
| 69 | + if (!$this->websocketHandler->onOpen($swooleRequest->fd, $illuminateRequest)) { |
|
| 70 | 70 | return; |
| 71 | 71 | } |
| 72 | 72 | // trigger 'connect' websocket event |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | public function onClose($server, $fd, $reactorId) |
| 132 | 132 | { |
| 133 | - if (! $this->isServerWebsocket($fd) || ! $server instanceof WebsocketServer) { |
|
| 133 | + if (!$this->isServerWebsocket($fd) || !$server instanceof WebsocketServer) { |
|
| 134 | 134 | return; |
| 135 | 135 | } |
| 136 | 136 | |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | */ |
| 159 | 159 | protected function isWebsocketPushPacket($packet) |
| 160 | 160 | { |
| 161 | - if (! is_array($packet)) { |
|
| 161 | + if (!is_array($packet)) { |
|
| 162 | 162 | return false; |
| 163 | 163 | } |
| 164 | 164 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | { |
| 244 | 244 | $handlerClass = $this->container->make('config')->get('swoole_websocket.handler'); |
| 245 | 245 | |
| 246 | - if (! $handlerClass) { |
|
| 246 | + if (!$handlerClass) { |
|
| 247 | 247 | throw new WebsocketNotSetInConfigException; |
| 248 | 248 | } |
| 249 | 249 | |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | */ |
| 291 | 291 | protected function bindRoom(): void |
| 292 | 292 | { |
| 293 | - $this->app->singleton(RoomContract::class, function (Container $container) { |
|
| 293 | + $this->app->singleton(RoomContract::class, function(Container $container) { |
|
| 294 | 294 | $config = $container->make('config'); |
| 295 | 295 | $driver = $config->get('swoole_websocket.default'); |
| 296 | 296 | $settings = $config->get("swoole_websocket.settings.{$driver}"); |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | */ |
| 312 | 312 | protected function bindWebsocket() |
| 313 | 313 | { |
| 314 | - $this->app->singleton(Websocket::class, function (Container $app) { |
|
| 314 | + $this->app->singleton(Websocket::class, function(Container $app) { |
|
| 315 | 315 | return new Websocket($app->make(RoomContract::class), new Pipeline($app)); |
| 316 | 316 | }); |
| 317 | 317 | |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | $routePath = $this->container->make('config') |
| 327 | 327 | ->get('swoole_websocket.route_file'); |
| 328 | 328 | |
| 329 | - if (! file_exists($routePath)) { |
|
| 329 | + if (!file_exists($routePath)) { |
|
| 330 | 330 | $routePath = __DIR__ . '/../../routes/websocket.php'; |
| 331 | 331 | } |
| 332 | 332 | |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | */ |
| 343 | 343 | public function isWebsocketPushPayload($payload): bool |
| 344 | 344 | { |
| 345 | - if (! is_array($payload)) { |
|
| 345 | + if (!is_array($payload)) { |
|
| 346 | 346 | return false; |
| 347 | 347 | } |
| 348 | 348 | |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | $options = $config->get('swoole_http.server.options'); |
| 150 | 150 | |
| 151 | 151 | // only enable task worker in websocket mode and for queue driver |
| 152 | - if ($config->get('queue.default') !== 'swoole' && ! $this->isWebsocket) { |
|
| 152 | + if ($config->get('queue.default') !== 'swoole' && !$this->isWebsocket) { |
|
| 153 | 153 | unset($options['task_worker_num']); |
| 154 | 154 | } |
| 155 | 155 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | protected function registerServer() |
| 165 | 165 | { |
| 166 | - $this->app->singleton(Server::class, function () { |
|
| 166 | + $this->app->singleton(Server::class, function() { |
|
| 167 | 167 | if (is_null(static::$server)) { |
| 168 | 168 | $this->createSwooleServer(); |
| 169 | 169 | $this->configureSwooleServer(); |
@@ -179,8 +179,8 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | protected function registerDatabaseDriver() |
| 181 | 181 | { |
| 182 | - $this->app->extend(DatabaseManager::class, function (DatabaseManager $db) { |
|
| 183 | - $db->extend('mysql-coroutine', function ($config, $name) { |
|
| 182 | + $this->app->extend(DatabaseManager::class, function(DatabaseManager $db) { |
|
| 183 | + $db->extend('mysql-coroutine', function($config, $name) { |
|
| 184 | 184 | $config['name'] = $name; |
| 185 | 185 | |
| 186 | 186 | $connection = new MySqlConnection( |
@@ -223,8 +223,8 @@ discard block |
||
| 223 | 223 | */ |
| 224 | 224 | protected function registerSwooleQueueDriver() |
| 225 | 225 | { |
| 226 | - $this->app->afterResolving('queue', function (QueueManager $manager) { |
|
| 227 | - $manager->addConnector('swoole', function () { |
|
| 226 | + $this->app->afterResolving('queue', function(QueueManager $manager) { |
|
| 227 | + $manager->addConnector('swoole', function() { |
|
| 228 | 228 | return new SwooleTaskConnector($this->app->make(Server::class)); |
| 229 | 229 | }); |
| 230 | 230 | }); |