Completed
Pull Request — master (#188)
by Albert
05:29
created
src/Websocket/Rooms/RedisRoom.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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.');
207 207
         }
208 208
     }
Please login to merge, or discard this patch.
src/Websocket/SocketIO/WebsocketHandler.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
      */
22 22
     public function onOpen($fd, Request $request)
23 23
     {
24
-        if (! $request->input('sid')) {
24
+        if (!$request->input('sid')) {
25 25
             $payload = json_encode(
26 26
                 [
27 27
                     'sid' => base64_encode(uniqid()),
Please login to merge, or discard this patch.
src/Websocket/Websocket.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
         $values = is_string($values) || is_integer($values) ? func_get_args() : $values;
113 113
 
114 114
         foreach ($values as $value) {
115
-            if (! in_array($value, $this->to)) {
115
+            if (!in_array($value, $this->to)) {
116 116
                 $this->to[] = $value;
117 117
             }
118 118
         }
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
     public function emit(string $event, $data): bool
164 164
     {
165 165
         $fds = $this->getFds();
166
-        $assigned = ! empty($this->to);
166
+        $assigned = !empty($this->to);
167 167
 
168 168
         // if no fds are found, but rooms are assigned
169 169
         // that means trying to emit to a non-existing room
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
      */
214 214
     public function on(string $event, $callback)
215 215
     {
216
-        if (! is_string($callback) && ! is_callable($callback)) {
216
+        if (!is_string($callback) && !is_callable($callback)) {
217 217
             throw new InvalidArgumentException(
218 218
                 'Invalid websocket callback. Must be a string or callable.'
219 219
             );
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
      */
247 247
     public function call(string $event, $data = null)
248 248
     {
249
-        if (! $this->eventExists($event)) {
249
+        if (!$this->eventExists($event)) {
250 250
             return null;
251 251
         }
252 252
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
      */
321 321
     protected function getFds()
322 322
     {
323
-        $fds = array_filter($this->to, function ($value) {
323
+        $fds = array_filter($this->to, function($value) {
324 324
             return is_integer($value);
325 325
         });
326 326
         $rooms = array_diff($this->to, $fds);
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
     {
400 400
         $pipeline = $this->pipeline;
401 401
 
402
-        $closure = function () use ($container) {
402
+        $closure = function() use ($container) {
403 403
             $this->container = $container;
404 404
         };
405 405
 
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
         return $this->pipeline
444 444
             ->send($request)
445 445
             ->through($this->middleware)
446
-            ->then(function ($request) {
446
+            ->then(function($request) {
447 447
                 return $request;
448 448
             });
449 449
     }
Please login to merge, or discard this patch.
src/Websocket/Authenticatable.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     {
64 64
         $users = is_object($users) ? func_get_args() : $users;
65 65
 
66
-        $userIds = array_map(function (AuthenticatableContract $user) {
66
+        $userIds = array_map(function(AuthenticatableContract $user) {
67 67
             $this->checkUser($user);
68 68
 
69 69
             return $user->getAuthIdentifier();
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      */
97 97
     public function getUserId()
98 98
     {
99
-        if (! is_null($this->userId)) {
99
+        if (!is_null($this->userId)) {
100 100
             return $this->userId;
101 101
         }
102 102
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
      */
121 121
     public function isUserIdOnline($userId)
122 122
     {
123
-        return ! empty($this->room->getClients(static::USER_PREFIX . $userId));
123
+        return !empty($this->room->getClients(static::USER_PREFIX . $userId));
124 124
     }
125 125
 
126 126
     /**
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      */
131 131
     protected function checkUser($user)
132 132
     {
133
-        if (! $user instanceOf AuthenticatableContract) {
133
+        if (!$user instanceOf AuthenticatableContract) {
134 134
             throw new InvalidArgumentException('user object must implement ' . AuthenticatableContract::class);
135 135
         }
136 136
     }
Please login to merge, or discard this patch.
src/Concerns/InteractsWithWebsocket.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
130 130
      */
131 131
     public function onClose($server, $fd, $reactorId)
132 132
     {
133
-        if (! $this->isServerWebsocket($fd) || ! $server instanceof Websocket) {
133
+        if (!$this->isServerWebsocket($fd) || !$server instanceof Websocket) {
134 134
             return;
135 135
         }
136 136
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         $payload = $this->payloadParser->encode($push->getEvent(), $push->getMessage());
164 164
 
165 165
         // attach sender if not broadcast
166
-        if (! $push->isBroadcast() && $push->getSender() && ! $push->hasOwnDescriptor()) {
166
+        if (!$push->isBroadcast() && $push->getSender() && !$push->hasOwnDescriptor()) {
167 167
             $push->addDescriptor($push->getSender());
168 168
         }
169 169
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 
175 175
         // push message to designated fds
176 176
         foreach ($push->getDescriptors() as $descriptor) {
177
-            if ($server->exist($descriptor) || ! $push->isBroadcastToDescriptor((int) $descriptor)) {
177
+            if ($server->exist($descriptor) || !$push->isBroadcastToDescriptor((int) $descriptor)) {
178 178
                 $server->push($descriptor, $payload, $push->getOpcode());
179 179
             }
180 180
         }
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
      */
242 242
     protected function filterWebsocket(array $descriptors): array
243 243
     {
244
-        $callback = function ($descriptor) {
244
+        $callback = function($descriptor) {
245 245
             return $this->isServerWebsocket($descriptor);
246 246
         };
247 247
 
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
     {
258 258
         $handlerClass = $this->container->make('config')->get('swoole_websocket.handler');
259 259
 
260
-        if (! $handlerClass) {
260
+        if (!$handlerClass) {
261 261
             throw new WebsocketNotSetInConfigException;
262 262
         }
263 263
 
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
      */
305 305
     protected function bindRoom(): void
306 306
     {
307
-        $this->app->singleton(RoomContract::class, function (Container $container) {
307
+        $this->app->singleton(RoomContract::class, function(Container $container) {
308 308
             $config = $container->make('config');
309 309
             $driver = $config->get('swoole_websocket.default');
310 310
             $settings = $config->get("swoole_websocket.settings.{$driver}");
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
      */
322 322
     protected function bindWebsocket()
323 323
     {
324
-        $this->app->singleton(Websocket::class, function (Container $app) {
324
+        $this->app->singleton(Websocket::class, function(Container $app) {
325 325
             return new Websocket($app->make(RoomContract::class), new Pipeline($app));
326 326
         });
327 327
 
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
         $routePath = $this->container->make('config')
337 337
             ->get('swoole_websocket.route_file');
338 338
 
339
-        if (! file_exists($routePath)) {
339
+        if (!file_exists($routePath)) {
340 340
             $routePath = __DIR__ . '/../../routes/websocket.php';
341 341
         }
342 342
 
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
      */
373 373
     protected function isWebsocketPushPayload($payload): bool
374 374
     {
375
-        if (! is_array($payload)) {
375
+        if (!is_array($payload)) {
376 376
             return false;
377 377
         }
378 378
 
Please login to merge, or discard this patch.
src/Concerns/WithApplication.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      */
58 58
     public function getApplication()
59 59
     {
60
-        if (! $this->app instanceof Container) {
60
+        if (!$this->app instanceof Container) {
61 61
             $this->app = $this->loadApplication();
62 62
             $this->bootstrap();
63 63
         }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
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 FrameworkNotSupportException($framework);
113 113
         }
114 114
 
Please login to merge, or discard this patch.
src/Concerns/InteractsWithSwooleTable.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -56,8 +56,8 @@
 block discarded – undo
56 56
      */
57 57
     protected function bindSwooleTable()
58 58
     {
59
-        if (! $this->app instanceof ConsoleApp) {
60
-            $this->app->singleton(SwooleTable::class, function () {
59
+        if (!$this->app instanceof ConsoleApp) {
60
+            $this->app->singleton(SwooleTable::class, function() {
61 61
                 return $this->currentTable;
62 62
             });
63 63
 
Please login to merge, or discard this patch.
src/Commands/HttpServerCommand.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
     {
134 134
         $pid = $this->getCurrentPid();
135 135
 
136
-        if (! $this->isRunning($pid)) {
136
+        if (!$this->isRunning($pid)) {
137 137
             $this->error("Failed! There is no swoole_http_server process running.");
138 138
 
139 139
             return;
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
     {
178 178
         $pid = $this->getCurrentPid();
179 179
 
180
-        if (! $this->isRunning($pid)) {
180
+        if (!$this->isRunning($pid)) {
181 181
             $this->error("Failed! There is no swoole_http_server process running.");
182 182
 
183 183
             return;
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 
188 188
         $isRunning = $this->killProcess($pid, SIGUSR1);
189 189
 
190
-        if (! $isRunning) {
190
+        if (!$isRunning) {
191 191
             $this->error('> failure');
192 192
 
193 193
             return;
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
     {
245 245
         $this->action = $this->argument('action');
246 246
 
247
-        if (! in_array($this->action, ['start', 'stop', 'restart', 'reload', 'infos'], true)) {
247
+        if (!in_array($this->action, ['start', 'stop', 'restart', 'reload', 'infos'], true)) {
248 248
             $this->error(
249 249
                 "Invalid argument '{$this->action}'. Expected 'start', 'stop', 'restart', 'reload' or 'infos'."
250 250
             );
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
         $filter = Arr::get($this->config, 'hot_reload.filter');
266 266
         $log = Arr::get($this->config, 'hot_reload.log');
267 267
 
268
-        $cb = function (FSEvent $event) use ($server, $log) {
268
+        $cb = function(FSEvent $event) use ($server, $log) {
269 269
             $log ? $this->info(FSOutput::format($event)) : null;
270 270
             $server->reload();
271 271
         };
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
      */
283 283
     protected function isRunning($pid)
284 284
     {
285
-        if (! $pid) {
285
+        if (!$pid) {
286 286
             return false;
287 287
         }
288 288
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
             $start = time();
311 311
 
312 312
             do {
313
-                if (! $this->isRunning($pid)) {
313
+                if (!$this->isRunning($pid)) {
314 314
                     break;
315 315
                 }
316 316
 
@@ -378,13 +378,13 @@  discard block
 block discarded – undo
378 378
             exit(1);
379 379
         }
380 380
 
381
-        if (! extension_loaded('swoole')) {
381
+        if (!extension_loaded('swoole')) {
382 382
             $this->error("Can't detect Swoole extension installed.");
383 383
 
384 384
             exit(1);
385 385
         }
386 386
 
387
-        if (! version_compare(swoole_version(), '4.0.0', 'ge')) {
387
+        if (!version_compare(swoole_version(), '4.0.0', 'ge')) {
388 388
             $this->error("Your Swoole version must be higher than 4.0 to use coroutine.");
389 389
 
390 390
             exit(1);
@@ -396,15 +396,15 @@  discard block
 block discarded – undo
396 396
      */
397 397
     protected function registerAccessLog()
398 398
     {
399
-        $this->laravel->singleton(OutputStyle::class, function () {
399
+        $this->laravel->singleton(OutputStyle::class, function() {
400 400
             return new OutputStyle($this->input, $this->output);
401 401
         });
402 402
 
403
-        $this->laravel->singleton(AccessOutput::class, function () {
403
+        $this->laravel->singleton(AccessOutput::class, function() {
404 404
             return new AccessOutput(new ConsoleOutput);
405 405
         });
406 406
 
407
-        $this->laravel->singleton(AccessLog::class, function (Container $container) {
407
+        $this->laravel->singleton(AccessLog::class, function(Container $container) {
408 408
             return new AccessLog($container->make(AccessOutput::class));
409 409
         });
410 410
     }
Please login to merge, or discard this patch.
src/Coroutine/Connectors/ConnectorFactory.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     public static function make(string $version): MySqlConnector
40 40
     {
41 41
         $isMatch = static::isFileVersionMatch($version);
42
-        $class = static::copy(static::stub($version), ! $isMatch);
42
+        $class = static::copy(static::stub($version), !$isMatch);
43 43
 
44 44
         return new $class;
45 45
     }
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
      */
65 65
     public static function copy(string $stub, bool $rewrite = false): string
66 66
     {
67
-        if (! file_exists(static::CONNECTOR_CLASS_PATH) || $rewrite) {
67
+        if (!file_exists(static::CONNECTOR_CLASS_PATH) || $rewrite) {
68 68
             copy($stub, static::CONNECTOR_CLASS_PATH);
69 69
         }
70 70
 
Please login to merge, or discard this patch.