@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function getApplication() |
| 63 | 63 | { |
| 64 | - if (! $this->app instanceof Container) { |
|
| 64 | + if (!$this->app instanceof Container) { |
|
| 65 | 65 | $this->app = $this->loadApplication(); |
| 66 | 66 | $this->bootstrap(); |
| 67 | 67 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | { |
| 109 | 109 | $framework = strtolower($framework); |
| 110 | 110 | |
| 111 | - if (! in_array($framework, ['laravel', 'lumen'])) { |
|
| 111 | + if (!in_array($framework, ['laravel', 'lumen'])) { |
|
| 112 | 112 | throw new \Exception(sprintf('Not support framework "%s".', $framework)); |
| 113 | 113 | } |
| 114 | 114 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | // enable sandbox |
| 55 | 55 | $this->app['swoole.sandbox']->enable(); |
| 56 | 56 | // check if socket.io connection established |
| 57 | - if (! $this->websocketHandler->onOpen($swooleRequest->fd, $illuminateRequest)) { |
|
| 57 | + if (!$this->websocketHandler->onOpen($swooleRequest->fd, $illuminateRequest)) { |
|
| 58 | 58 | return; |
| 59 | 59 | } |
| 60 | 60 | // trigger 'connect' websocket event |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | public function onClose($server, $fd, $reactorId) |
| 118 | 118 | { |
| 119 | - if (! $this->isWebsocket($fd)) { |
|
| 119 | + if (!$this->isWebsocket($fd)) { |
|
| 120 | 120 | return; |
| 121 | 121 | } |
| 122 | 122 | |
@@ -147,12 +147,12 @@ discard block |
||
| 147 | 147 | $message = $this->parser->encode($event, $message); |
| 148 | 148 | |
| 149 | 149 | // attach sender if not broadcast |
| 150 | - if (! $broadcast && $sender && ! in_array($sender, $fds)) { |
|
| 150 | + if (!$broadcast && $sender && !in_array($sender, $fds)) { |
|
| 151 | 151 | $fds[] = $sender; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | // check if to broadcast all clients |
| 155 | - if ($broadcast && empty($fds) && ! $assigned) { |
|
| 155 | + if ($broadcast && empty($fds) && !$assigned) { |
|
| 156 | 156 | foreach ($server->connections as $fd) { |
| 157 | 157 | if ($this->isWebsocket($fd)) { |
| 158 | 158 | $fds[] = $fd; |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | // push message to designated fds |
| 164 | 164 | foreach ($fds as $fd) { |
| 165 | - if (($broadcast && $sender === (integer) $fd) || ! $server->exist($fd)) { |
|
| 165 | + if (($broadcast && $sender === (integer) $fd) || !$server->exist($fd)) { |
|
| 166 | 166 | continue; |
| 167 | 167 | } |
| 168 | 168 | $server->push($fd, $message, $opcode); |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | { |
| 222 | 222 | $handlerClass = $this->container['config']->get('swoole_websocket.handler'); |
| 223 | 223 | |
| 224 | - if (! $handlerClass) { |
|
| 224 | + if (!$handlerClass) { |
|
| 225 | 225 | throw new Exception('Websocket handler is not set in swoole_websocket config'); |
| 226 | 226 | } |
| 227 | 227 | |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | */ |
| 267 | 267 | protected function bindRoom() |
| 268 | 268 | { |
| 269 | - $this->app->singleton(RoomContract::class, function ($app) { |
|
| 269 | + $this->app->singleton(RoomContract::class, function($app) { |
|
| 270 | 270 | return $this->getWebsocketRoom(); |
| 271 | 271 | }); |
| 272 | 272 | $this->app->alias(RoomContract::class, 'swoole.room'); |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | */ |
| 278 | 278 | protected function bindWebsocket() |
| 279 | 279 | { |
| 280 | - $this->app->singleton(Websocket::class, function ($app) { |
|
| 280 | + $this->app->singleton(Websocket::class, function($app) { |
|
| 281 | 281 | return new Websocket($app['swoole.room'], new Pipeline($app)); |
| 282 | 282 | }); |
| 283 | 283 | $this->app->alias(Websocket::class, 'swoole.websocket'); |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | { |
| 291 | 291 | $routePath = $this->container['config']->get('swoole_websocket.route_file'); |
| 292 | 292 | |
| 293 | - if (! file_exists($routePath)) { |
|
| 293 | + if (!file_exists($routePath)) { |
|
| 294 | 294 | $routePath = __DIR__ . '/../../routes/websocket.php'; |
| 295 | 295 | } |
| 296 | 296 | |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | */ |
| 50 | 50 | protected function bindSwooleTable() |
| 51 | 51 | { |
| 52 | - $this->app->singleton(SwooleTable::class, function () { |
|
| 52 | + $this->app->singleton(SwooleTable::class, function() { |
|
| 53 | 53 | return $this->table; |
| 54 | 54 | }); |
| 55 | 55 | $this->app->alias(SwooleTable::class, 'swoole.table'); |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | protected function registerManager() |
| 15 | 15 | { |
| 16 | - $this->app->singleton('swoole.manager', function ($app) { |
|
| 16 | + $this->app->singleton('swoole.manager', function($app) { |
|
| 17 | 17 | return new Manager($app, 'laravel'); |
| 18 | 18 | }); |
| 19 | 19 | } |
@@ -25,6 +25,6 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | protected function bootRoutes() |
| 27 | 27 | { |
| 28 | - require __DIR__.'/../routes/laravel_routes.php'; |
|
| 28 | + require __DIR__ . '/../routes/laravel_routes.php'; |
|
| 29 | 29 | } |
| 30 | 30 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | public function bindParam($parameter, &$variable, $type = null, $maxlen = null, $driverdata = null) |
| 50 | 50 | { |
| 51 | - if (! is_string($parameter) && ! is_int($parameter)) { |
|
| 51 | + if (!is_string($parameter) && !is_int($parameter)) { |
|
| 52 | 52 | return false; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -60,12 +60,12 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | public function bindValue($parameter, $variable, $type = null) |
| 62 | 62 | { |
| 63 | - if (! is_string($parameter) && ! is_int($parameter)) { |
|
| 63 | + if (!is_string($parameter) && !is_int($parameter)) { |
|
| 64 | 64 | return false; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | if (is_object($variable)) { |
| 68 | - if (! method_exists($variable, '__toString')) { |
|
| 68 | + if (!method_exists($variable, '__toString')) { |
|
| 69 | 69 | return false; |
| 70 | 70 | } else { |
| 71 | 71 | $variable = (string) $variable; |
@@ -86,14 +86,14 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | public function execute($inputParameters = null) |
| 88 | 88 | { |
| 89 | - if (! empty($inputParameters)) { |
|
| 89 | + if (!empty($inputParameters)) { |
|
| 90 | 90 | foreach ($inputParameters as $key => $value) { |
| 91 | 91 | $this->bindParam($key, $value); |
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | $inputParameters = []; |
| 96 | - if (! empty($this->statement->bindKeyMap)) { |
|
| 96 | + if (!empty($this->statement->bindKeyMap)) { |
|
| 97 | 97 | foreach ($this->statement->bindKeyMap as $nameKey => $numKey) { |
| 98 | 98 | $inputParameters[$numKey] = $this->bindMap[$nameKey]; |
| 99 | 99 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | $fetchArgument = null, |
| 144 | 144 | $ctorArgs = null |
| 145 | 145 | ) { |
| 146 | - if (! is_array($rawData)) { |
|
| 146 | + if (!is_array($rawData)) { |
|
| 147 | 147 | return false; |
| 148 | 148 | } |
| 149 | 149 | if (empty($rawData)) { |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | { |
| 57 | 57 | $this->client->connect($options); |
| 58 | 58 | |
| 59 | - if (! $this->client->connected) { |
|
| 59 | + if (!$this->client->connected) { |
|
| 60 | 60 | $message = $this->client->connect_error ?: $this->client->error; |
| 61 | 61 | $errorCode = $this->client->connect_errno ?: $this->client->errno; |
| 62 | 62 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | public static function checkDriver(string $driver) |
| 103 | 103 | { |
| 104 | - if (! in_array($driver, static::getAvailableDrivers())) { |
|
| 104 | + if (!in_array($driver, static::getAvailableDrivers())) { |
|
| 105 | 105 | throw new \InvalidArgumentException("{$driver} driver is not supported yet."); |
| 106 | 106 | } |
| 107 | 107 | } |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | $bindKeyMap = []; |
| 186 | 186 | $statement = preg_replace_callback( |
| 187 | 187 | '/:(\w+)\b/', |
| 188 | - function ($matches) use (&$i, &$bindKeyMap) { |
|
| 188 | + function($matches) use (&$i, &$bindKeyMap) { |
|
| 189 | 189 | $bindKeyMap[$matches[1]] = $i++; |
| 190 | 190 | |
| 191 | 191 | return '?'; |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | protected function registerManager() |
| 15 | 15 | { |
| 16 | - $this->app->singleton('swoole.manager', function ($app) { |
|
| 16 | + $this->app->singleton('swoole.manager', function($app) { |
|
| 17 | 17 | return new Manager($app, 'lumen'); |
| 18 | 18 | }); |
| 19 | 19 | } |
@@ -28,11 +28,11 @@ discard block |
||
| 28 | 28 | $app = $this->app; |
| 29 | 29 | |
| 30 | 30 | if (property_exists($app, 'router')) { |
| 31 | - $app->router->group(['namespace' => 'SwooleTW\Http\Controllers'], function ($app) { |
|
| 31 | + $app->router->group(['namespace' => 'SwooleTW\Http\Controllers'], function($app) { |
|
| 32 | 32 | require __DIR__ . '/../routes/lumen_routes.php'; |
| 33 | 33 | }); |
| 34 | 34 | } else { |
| 35 | - $app->group(['namespace' => 'App\Http\Controllers'], function ($app) { |
|
| 35 | + $app->group(['namespace' => 'App\Http\Controllers'], function($app) { |
|
| 36 | 36 | require __DIR__ . '/../routes/lumen_routes.php'; |
| 37 | 37 | }); |
| 38 | 38 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | $key = str_replace('-', '_', $key); |
| 152 | 152 | $key = strtoupper($key); |
| 153 | 153 | |
| 154 | - if (! in_array($key, ['REMOTE_ADDR', 'SERVER_PORT', 'HTTPS'])) { |
|
| 154 | + if (!in_array($key, ['REMOTE_ADDR', 'SERVER_PORT', 'HTTPS'])) { |
|
| 155 | 155 | $key = 'HTTP_' . $key; |
| 156 | 156 | } |
| 157 | 157 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | $filename = $publicPath . $uri; |
| 181 | - if (! is_file($filename) || filesize($filename) === 0) { |
|
| 181 | + if (!is_file($filename) || filesize($filename) === 0) { |
|
| 182 | 182 | return; |
| 183 | 183 | } |
| 184 | 184 | |
@@ -14,12 +14,12 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | protected $swoole; |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Create a new Swoole Async task connector instance. |
|
| 19 | - * |
|
| 20 | - * @param \Swoole\Http\Server $swoole |
|
| 21 | - * @return void |
|
| 22 | - */ |
|
| 17 | + /** |
|
| 18 | + * Create a new Swoole Async task connector instance. |
|
| 19 | + * |
|
| 20 | + * @param \Swoole\Http\Server $swoole |
|
| 21 | + * @return void |
|
| 22 | + */ |
|
| 23 | 23 | public function __construct($swoole) |
| 24 | 24 | { |
| 25 | 25 | $this->swoole = $swoole; |