@@ -16,7 +16,7 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | protected function registerManager() |
| 18 | 18 | { |
| 19 | - $this->app->singleton(Manager::class, function ($app) { |
|
| 19 | + $this->app->singleton(Manager::class, function($app) { |
|
| 20 | 20 | return new Manager($app, 'laravel'); |
| 21 | 21 | }); |
| 22 | 22 | |
@@ -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', 3); |
| 22 | 22 | } |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function make(?callable $callback = null) |
| 64 | 64 | { |
| 65 | - $mcb = function ($type, $buffer) use ($callback) { |
|
| 66 | - if (! $this->locked && AppProcess::OUT === $type && $event = FSEventParser::toEvent($buffer)) { |
|
| 65 | + $mcb = function($type, $buffer) use ($callback) { |
|
| 66 | + if (!$this->locked && AppProcess::OUT === $type && $event = FSEventParser::toEvent($buffer)) { |
|
| 67 | 67 | $this->locked = true; |
| 68 | 68 | ($callback) ? $callback($event) : null; |
| 69 | 69 | $this->locked = false; |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | } |
| 72 | 72 | }; |
| 73 | 73 | |
| 74 | - return new SwooleProcess(function () use ($mcb) { |
|
| 74 | + return new SwooleProcess(function() use ($mcb) { |
|
| 75 | 75 | (new AppProcess($this->configure()))->setTimeout(0)->run($mcb); |
| 76 | 76 | }, false, false); |
| 77 | 77 | } |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | protected function isSwooleQueuePacket($packet) |
| 16 | 16 | { |
| 17 | - if (! is_string($packet)) { |
|
| 17 | + if (!is_string($packet)) { |
|
| 18 | 18 | return false; |
| 19 | 19 | } |
| 20 | 20 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function setRedis(?RedisClient $redis = null) |
| 59 | 59 | { |
| 60 | - if (! $redis) { |
|
| 60 | + if (!$redis) { |
|
| 61 | 61 | $server = Arr::get($this->config, 'server', []); |
| 62 | 62 | $options = Arr::get($this->config, 'options', []); |
| 63 | 63 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $this->checkTable($table); |
| 140 | 140 | $redisKey = $this->getKey($key, $table); |
| 141 | 141 | |
| 142 | - $this->redis->pipeline(function (Pipeline $pipe) use ($redisKey, $values) { |
|
| 142 | + $this->redis->pipeline(function(Pipeline $pipe) use ($redisKey, $values) { |
|
| 143 | 143 | foreach ($values as $value) { |
| 144 | 144 | $pipe->sadd($redisKey, $value); |
| 145 | 145 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | $this->checkTable($table); |
| 163 | 163 | $redisKey = $this->getKey($key, $table); |
| 164 | 164 | |
| 165 | - $this->redis->pipeline(function (Pipeline $pipe) use ($redisKey, $values) { |
|
| 165 | + $this->redis->pipeline(function(Pipeline $pipe) use ($redisKey, $values) { |
|
| 166 | 166 | foreach ($values as $value) { |
| 167 | 167 | $pipe->srem($redisKey, $value); |
| 168 | 168 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | protected function checkTable(string $table) |
| 204 | 204 | { |
| 205 | - if (! in_array($table, [RoomContract::ROOMS_KEY, RoomContract::DESCRIPTORS_KEY])) { |
|
| 205 | + if (!in_array($table, [RoomContract::ROOMS_KEY, RoomContract::DESCRIPTORS_KEY])) { |
|
| 206 | 206 | throw new \InvalidArgumentException("Invalid table name: `{$table}`."); |
| 207 | 207 | } |
| 208 | 208 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | foreach ($rooms as $room) { |
| 88 | 88 | $fds = $this->getClients($room); |
| 89 | 89 | |
| 90 | - if (! in_array($fd, $fds)) { |
|
| 90 | + if (!in_array($fd, $fds)) { |
|
| 91 | 91 | continue; |
| 92 | 92 | } |
| 93 | 93 | |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | protected function checkTable(string $table) |
| 208 | 208 | { |
| 209 | - if (! property_exists($this, $table) || ! $this->$table instanceof Table) { |
|
| 209 | + if (!property_exists($this, $table) || !$this->$table instanceof Table) { |
|
| 210 | 210 | throw new \InvalidArgumentException("Invalid table name: `{$table}`."); |
| 211 | 211 | } |
| 212 | 212 | } |
@@ -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; |
@@ -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 | }); |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | public static function dump(...$args) |
| 14 | 14 | { |
| 15 | - if (! static::$cloner instanceOf VarCloner) { |
|
| 15 | + if (!static::$cloner instanceOf VarCloner) { |
|
| 16 | 16 | static::$cloner = new VarCloner; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | public static function getDumper() |
| 31 | 31 | { |
| 32 | - $dumper = defined('IN_PHPUNIT') || ! config('swoole_http.ob_output') |
|
| 32 | + $dumper = defined('IN_PHPUNIT') || !config('swoole_http.ob_output') |
|
| 33 | 33 | ? CliDumper::class |
| 34 | 34 | : HtmlDumper::class; |
| 35 | 35 | |