@@ -20,7 +20,7 @@ |
||
| 20 | 20 | if ($sandbox->isLaravel()) { |
| 21 | 21 | $kernel = $app->make(Kernel::class); |
| 22 | 22 | |
| 23 | - $closure = function () use ($app) { |
|
| 23 | + $closure = function() use ($app) { |
|
| 24 | 24 | $this->app = $app; |
| 25 | 25 | }; |
| 26 | 26 | |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | { |
| 19 | 19 | $view = $app->make('view'); |
| 20 | 20 | |
| 21 | - $closure = function () use ($app) { |
|
| 21 | + $closure = function() use ($app) { |
|
| 22 | 22 | $this->container = $app; |
| 23 | 23 | $this->shared['app'] = $app; |
| 24 | 24 | }; |
@@ -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() |
| 8 | 8 | { |
| 9 | 9 | return; |
@@ -13,6 +13,6 @@ 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 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function __construct($app = null, $framework = null) |
| 36 | 36 | { |
| 37 | - if (! $app instanceof Container) { |
|
| 37 | + if (!$app instanceof Container) { |
|
| 38 | 38 | return; |
| 39 | 39 | } |
| 40 | 40 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function initialize() |
| 104 | 104 | { |
| 105 | - if (! $this->app instanceof Container) { |
|
| 105 | + if (!$this->app instanceof Container) { |
|
| 106 | 106 | throw new SandboxException('A base app has not been set.'); |
| 107 | 107 | } |
| 108 | 108 | |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | public function run(Request $request) |
| 151 | 151 | { |
| 152 | - if (! $this->getSnapshot() instanceof Container) { |
|
| 152 | + if (!$this->getSnapshot() instanceof Container) { |
|
| 153 | 153 | throw new SandboxException('Sandbox is not enabled.'); |
| 154 | 154 | } |
| 155 | 155 | |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | $response->sendContent(); |
| 200 | 200 | } elseif ($response instanceof SymfonyResponse) { |
| 201 | 201 | $content = $response->getContent(); |
| 202 | - } elseif (! $isFile = $response instanceof BinaryFileResponse) { |
|
| 202 | + } elseif (!$isFile = $response instanceof BinaryFileResponse) { |
|
| 203 | 203 | $content = (string) $response; |
| 204 | 204 | } |
| 205 | 205 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | $this->terminate($request, $response); |
| 208 | 208 | |
| 209 | 209 | // append ob content to response |
| 210 | - if (! $isFile && ob_get_length() > 0) { |
|
| 210 | + if (!$isFile && ob_get_length() > 0) { |
|
| 211 | 211 | if ($isStream) { |
| 212 | 212 | $response->output = ob_get_contents(); |
| 213 | 213 | } else { |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | */ |
| 281 | 281 | public function enable() |
| 282 | 282 | { |
| 283 | - if (! $this->config instanceof ConfigContract) { |
|
| 283 | + if (!$this->config instanceof ConfigContract) { |
|
| 284 | 284 | throw new SandboxException('Please initialize after setting base app.'); |
| 285 | 285 | } |
| 286 | 286 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | { |
| 107 | 107 | $pid = $this->getPid(); |
| 108 | 108 | |
| 109 | - if (! $this->isRunning($pid)) { |
|
| 109 | + if (!$this->isRunning($pid)) { |
|
| 110 | 110 | $this->error("Failed! There is no swoole_http_server process running."); |
| 111 | 111 | exit(1); |
| 112 | 112 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | { |
| 149 | 149 | $pid = $this->getPid(); |
| 150 | 150 | |
| 151 | - if (! $this->isRunning($pid)) { |
|
| 151 | + if (!$this->isRunning($pid)) { |
|
| 152 | 152 | $this->error("Failed! There is no swoole_http_server process running."); |
| 153 | 153 | exit(1); |
| 154 | 154 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | $isRunning = $this->killProcess($pid, SIGUSR1); |
| 159 | 159 | |
| 160 | - if (! $isRunning) { |
|
| 160 | + if (!$isRunning) { |
|
| 161 | 161 | $this->error('> failure'); |
| 162 | 162 | exit(1); |
| 163 | 163 | } |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | { |
| 216 | 216 | $this->action = $this->argument('action'); |
| 217 | 217 | |
| 218 | - if (! in_array($this->action, ['start', 'stop', 'restart', 'reload', 'infos'])) { |
|
| 218 | + if (!in_array($this->action, ['start', 'stop', 'restart', 'reload', 'infos'])) { |
|
| 219 | 219 | $this->error("Invalid argument '{$this->action}'. Expected 'start', 'stop', 'restart', 'reload' or 'infos'."); |
| 220 | 220 | exit(1); |
| 221 | 221 | } |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | protected function isRunning($pid) |
| 231 | 231 | { |
| 232 | - if (! $pid) { |
|
| 232 | + if (!$pid) { |
|
| 233 | 233 | return false; |
| 234 | 234 | } |
| 235 | 235 | |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | $start = time(); |
| 257 | 257 | |
| 258 | 258 | do { |
| 259 | - if (! $this->isRunning($pid)) { |
|
| 259 | + if (!$this->isRunning($pid)) { |
|
| 260 | 260 | break; |
| 261 | 261 | } |
| 262 | 262 | |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | if (file_exists($path)) { |
| 285 | 285 | $pid = (int) file_get_contents($path); |
| 286 | 286 | |
| 287 | - if (! $pid) { |
|
| 287 | + if (!$pid) { |
|
| 288 | 288 | $this->removePidFile(); |
| 289 | 289 | } else { |
| 290 | 290 | $this->pid = $pid; |
@@ -330,10 +330,10 @@ discard block |
||
| 330 | 330 | if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
| 331 | 331 | $this->error("Swoole extension doesn't support Windows OS yet."); |
| 332 | 332 | exit; |
| 333 | - } elseif (! extension_loaded('swoole')) { |
|
| 333 | + } elseif (!extension_loaded('swoole')) { |
|
| 334 | 334 | $this->error("Can't detect Swoole extension installed."); |
| 335 | 335 | exit; |
| 336 | - } elseif (! version_compare(swoole_version(), '4.0.0', 'ge')) { |
|
| 336 | + } elseif (!version_compare(swoole_version(), '4.0.0', 'ge')) { |
|
| 337 | 337 | $this->error("Your Swoole version must be higher than 4.0 to use coroutine."); |
| 338 | 338 | exit; |
| 339 | 339 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | foreach ($rooms as $room) { |
| 56 | 56 | $fds = $this->getClients($room); |
| 57 | 57 | |
| 58 | - if (! in_array($fd, $fds)) { |
|
| 58 | + if (!in_array($fd, $fds)) { |
|
| 59 | 59 | continue; |
| 60 | 60 | } |
| 61 | 61 | |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | protected function checkTable(string $table) |
| 124 | 124 | { |
| 125 | - if (! property_exists($this, $table) || ! $this->$table instanceof Table) { |
|
| 125 | + if (!property_exists($this, $table) || !$this->$table instanceof Table) { |
|
| 126 | 126 | throw new \InvalidArgumentException('Invalid table name.'); |
| 127 | 127 | } |
| 128 | 128 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | $this->checkTable($table); |
| 92 | 92 | $redisKey = $this->getKey($key, $table); |
| 93 | 93 | |
| 94 | - $this->redis->pipeline(function ($pipe) use ($redisKey, $values) { |
|
| 94 | + $this->redis->pipeline(function($pipe) use ($redisKey, $values) { |
|
| 95 | 95 | foreach ($values as $value) { |
| 96 | 96 | $pipe->sadd($redisKey, $value); |
| 97 | 97 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $this->checkTable($table); |
| 106 | 106 | $redisKey = $this->getKey($key, $table); |
| 107 | 107 | |
| 108 | - $this->redis->pipeline(function ($pipe) use ($redisKey, $values) { |
|
| 108 | + $this->redis->pipeline(function($pipe) use ($redisKey, $values) { |
|
| 109 | 109 | foreach ($values as $value) { |
| 110 | 110 | $pipe->srem($redisKey, $value); |
| 111 | 111 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | protected function checkTable(string $table) |
| 128 | 128 | { |
| 129 | - if (! in_array($table, ['rooms', 'fds'])) { |
|
| 129 | + if (!in_array($table, ['rooms', 'fds'])) { |
|
| 130 | 130 | throw new \InvalidArgumentException('Invalid table name.'); |
| 131 | 131 | } |
| 132 | 132 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | $providers = $this->config->get('swoole_http.providers', []); |
| 49 | 49 | |
| 50 | 50 | foreach ($providers as $provider) { |
| 51 | - if (class_exists($provider) && ! in_array($provider, $this->providers)) { |
|
| 51 | + if (class_exists($provider) && !in_array($provider, $this->providers)) { |
|
| 52 | 52 | $providerClass = new $provider($app); |
| 53 | 53 | $this->providers[$provider] = $providerClass; |
| 54 | 54 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | foreach ($resetters as $resetter) { |
| 75 | 75 | $resetterClass = $app->make($resetter); |
| 76 | - if (! $resetterClass instanceof ResetterContract) { |
|
| 76 | + if (!$resetterClass instanceof ResetterContract) { |
|
| 77 | 77 | throw new SandboxException("{$resetter} must implement " . ResetterContract::class); |
| 78 | 78 | } |
| 79 | 79 | $this->resetters[$resetter] = $resetterClass; |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | if (method_exists($this, $listener)) { |
| 104 | 104 | $this->container['swoole.server']->on($event, [$this, $listener]); |
| 105 | 105 | } else { |
| 106 | - $this->container['swoole.server']->on($event, function () use ($event) { |
|
| 106 | + $this->container['swoole.server']->on($event, function() use ($event) { |
|
| 107 | 107 | $event = sprintf('swoole.%s', $event); |
| 108 | 108 | |
| 109 | 109 | $this->container['events']->fire($event, func_get_args()); |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | // don't init laravel app in task workers |
| 147 | 147 | if ($server->taskworker) { |
| 148 | - $this->setProcessName('task process');//mark task process |
|
| 148 | + $this->setProcessName('task process'); //mark task process |
|
| 149 | 149 | return; |
| 150 | 150 | } |
| 151 | 151 | $this->setProcessName('worker process'); |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | (new SwooleTaskJob($this->container, $server, $data, $taskId, $srcWorkerId))->fire(); |
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | - $server->finish("$taskId finished");//if not ,don't call onFinish |
|
| 248 | + $server->finish("$taskId finished"); //if not ,don't call onFinish |
|
| 249 | 249 | } catch (Throwable $e) { |
| 250 | 250 | $this->logServerError($e); |
| 251 | 251 | } |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | */ |
| 289 | 289 | protected function bindSandbox() |
| 290 | 290 | { |
| 291 | - $this->app->singleton(Sandbox::class, function ($app) { |
|
| 291 | + $this->app->singleton(Sandbox::class, function($app) { |
|
| 292 | 292 | return new Sandbox($app, $this->framework); |
| 293 | 293 | }); |
| 294 | 294 | $this->app->alias(Sandbox::class, 'swoole.sandbox'); |