Completed
Branch master (d0700c)
by Albert
06:23 queued 04:08
created
Category
src/Commands/HttpServerCommand.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     {
103 103
         $pid = $this->getPid();
104 104
 
105
-        if (! $this->isRunning($pid)) {
105
+        if (!$this->isRunning($pid)) {
106 106
             $this->error("Failed! There is no swoole_http_server process running.");
107 107
             exit(1);
108 108
         }
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
     {
145 145
         $pid = $this->getPid();
146 146
 
147
-        if (! $this->isRunning($pid)) {
147
+        if (!$this->isRunning($pid)) {
148 148
             $this->error("Failed! There is no swoole_http_server process running.");
149 149
             exit(1);
150 150
         }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 
154 154
         $isRunning = $this->killProcess($pid, SIGUSR1);
155 155
 
156
-        if (! $isRunning) {
156
+        if (!$isRunning) {
157 157
             $this->error('> failure');
158 158
             exit(1);
159 159
         }
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
     {
212 212
         $this->action = $this->argument('action');
213 213
 
214
-        if (! in_array($this->action, ['start', 'stop', 'restart', 'reload', 'infos'])) {
214
+        if (!in_array($this->action, ['start', 'stop', 'restart', 'reload', 'infos'])) {
215 215
             $this->error("Invalid argument '{$this->action}'. Expected 'start', 'stop', 'restart', 'reload' or 'infos'.");
216 216
             exit(1);
217 217
         }
@@ -225,13 +225,13 @@  discard block
 block discarded – undo
225 225
      */
226 226
     protected function isRunning($pid)
227 227
     {
228
-        if (! $pid) {
228
+        if (!$pid) {
229 229
             return false;
230 230
         }
231 231
 
232 232
         Process::kill($pid, 0);
233 233
 
234
-        return ! swoole_errno();
234
+        return !swoole_errno();
235 235
     }
236 236
 
237 237
     /**
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
             $start = time();
251 251
 
252 252
             do {
253
-                if (! $this->isRunning($pid)) {
253
+                if (!$this->isRunning($pid)) {
254 254
                     break;
255 255
                 }
256 256
 
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
         if (file_exists($path)) {
279 279
             $pid = (int) file_get_contents($path);
280 280
 
281
-            if (! $pid) {
281
+            if (!$pid) {
282 282
                 $this->removePidFile();
283 283
             } else {
284 284
                 $this->pid = $pid;
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
     {
324 324
         if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
325 325
             throw new \RuntimeException("Swoole extension doesn't support Windows OS yet.");
326
-        } elseif (! extension_loaded('swoole')) {
326
+        } elseif (!extension_loaded('swoole')) {
327 327
             throw new \RuntimeException("Can't detect Swoole extension installed.");
328 328
         }
329 329
     }
Please login to merge, or discard this patch.
src/Websocket/Rooms/RedisRoom.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/Websocket/Rooms/TableRoom.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/Websocket/SocketIO/Packet.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@
 block discarded – undo
107 107
     {
108 108
         $type = $packet[0] ?? null;
109 109
 
110
-        if (! array_key_exists($type, static::$socketTypes)) {
110
+        if (!array_key_exists($type, static::$socketTypes)) {
111 111
             return null;
112 112
         }
113 113
 
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
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
      */
19 19
     public function onOpen($fd, Request $request)
20 20
     {
21
-        if (! $request->input('sid')) {
21
+        if (!$request->input('sid')) {
22 22
             $payload = json_encode([
23 23
                 'sid' => base64_encode(uniqid()),
24 24
                 'upgrades' => [],
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
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     {
45 45
         $users = is_object($users) ? func_get_args() : $users;
46 46
 
47
-        $userIds = array_map(function ($user) {
47
+        $userIds = array_map(function($user) {
48 48
             $this->checkUser($user);
49 49
             return $user->getAuthIdentifier();
50 50
         }, $users);
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function getUserId()
74 74
     {
75
-        if (! is_null($this->userId)) {
75
+        if (!is_null($this->userId)) {
76 76
             return $this->userId;
77 77
         }
78 78
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      */
93 93
     public function isUserIdOnline($userId)
94 94
     {
95
-        return ! empty($this->room->getClients(static::USER_PREFIX . $userId));
95
+        return !empty($this->room->getClients(static::USER_PREFIX . $userId));
96 96
     }
97 97
 
98 98
     /**
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
      */
101 101
     protected function checkUser($user)
102 102
     {
103
-        if (! $user instanceOf AuthenticatableContract) {
103
+        if (!$user instanceOf AuthenticatableContract) {
104 104
             throw new InvalidArgumentException('user object must implement ' . AuthenticatableContract::class);
105 105
         }
106 106
     }
Please login to merge, or discard this patch.
src/Websocket/CanWebsocket.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
             $application = $this->sandbox->getLaravelApp();
66 66
             $this->sandbox->enable();
67 67
             // check if socket.io connection established
68
-            if (! $this->websocketHandler->onOpen($swooleRequest->fd, $illuminateRequest)) {
68
+            if (!$this->websocketHandler->onOpen($swooleRequest->fd, $illuminateRequest)) {
69 69
                 return;
70 70
             }
71 71
             // trigger 'connect' websocket event
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      */
131 131
     public function onClose(Server $server, $fd, $reactorId)
132 132
     {
133
-        if (! $this->isWebsocket($fd)) {
133
+        if (!$this->isWebsocket($fd)) {
134 134
             return;
135 135
         }
136 136
 
@@ -161,12 +161,12 @@  discard block
 block discarded – undo
161 161
         $message = $this->parser->encode($event, $message);
162 162
 
163 163
         // attach sender if not broadcast
164
-        if (! $broadcast && $sender && ! in_array($sender, $fds)) {
164
+        if (!$broadcast && $sender && !in_array($sender, $fds)) {
165 165
             $fds[] = $sender;
166 166
         }
167 167
 
168 168
         // check if to broadcast all clients
169
-        if ($broadcast && empty($fds) && ! $assigned) {
169
+        if ($broadcast && empty($fds) && !$assigned) {
170 170
             foreach ($server->connections as $fd) {
171 171
                 if ($this->isWebsocket($fd)) {
172 172
                     $fds[] = $fd;
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
         // push message to designated fds
178 178
         foreach ($fds as $fd) {
179
-            if (($broadcast && $sender === (integer) $fd) || ! $server->exist($fd)) {
179
+            if (($broadcast && $sender === (integer) $fd) || !$server->exist($fd)) {
180 180
                 continue;
181 181
             }
182 182
             $server->push($fd, $message, $opcode);
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
     {
221 221
         $handlerClass = $this->container['config']->get('swoole_websocket.handler');
222 222
 
223
-        if (! $handlerClass) {
223
+        if (!$handlerClass) {
224 224
             throw new Exception('websocket handler not set in swoole_websocket config');
225 225
         }
226 226
 
227 227
         $handler = $this->app->make($handlerClass);
228 228
 
229
-        if (! $handler instanceof HandlerContract) {
229
+        if (!$handler instanceof HandlerContract) {
230 230
             throw new Exception(sprintf('%s must implement %s', get_class($handler), HandlerContract::class));
231 231
         }
232 232
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      */
252 252
     protected function bindRoom()
253 253
     {
254
-        $this->app->singleton(RoomContract::class, function ($app) {
254
+        $this->app->singleton(RoomContract::class, function($app) {
255 255
             return $this->websocketRoom;
256 256
         });
257 257
         $this->app->alias(RoomContract::class, 'swoole.room');
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
      */
263 263
     protected function bindWebsocket()
264 264
     {
265
-        $this->app->singleton(Websocket::class, function ($app) {
265
+        $this->app->singleton(Websocket::class, function($app) {
266 266
             return $this->websocket = new Websocket($app['swoole.room'], new Pipeline);
267 267
         });
268 268
         $this->app->alias(Websocket::class, 'swoole.websocket');
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
     {
276 276
         $routePath = $this->container['config']->get('swoole_websocket.route_file');
277 277
 
278
-        if (! file_exists($routePath)) {
278
+        if (!file_exists($routePath)) {
279 279
             $routePath = __DIR__ . '/../../routes/websocket.php';
280 280
         }
281 281
 
Please login to merge, or discard this patch.
src/Websocket/Middleware/StartSession.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      */
54 54
     protected function startSession(Request $request)
55 55
     {
56
-        return tap($this->getSession($request), function ($session) use ($request) {
56
+        return tap($this->getSession($request), function($session) use ($request) {
57 57
             $session->setRequestOnHandler($request);
58 58
 
59 59
             $session->start();
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function getSession(Request $request)
70 70
     {
71
-        return tap($this->manager->driver(), function ($session) use ($request) {
71
+        return tap($this->manager->driver(), function($session) use ($request) {
72 72
             $session->setId($request->cookies->get($session->getName()));
73 73
         });
74 74
     }
@@ -80,6 +80,6 @@  discard block
 block discarded – undo
80 80
      */
81 81
     protected function sessionConfigured()
82 82
     {
83
-        return ! is_null($this->manager->getSessionConfig()['driver'] ?? null);
83
+        return !is_null($this->manager->getSessionConfig()['driver'] ?? null);
84 84
     }
85 85
 }
Please login to merge, or discard this patch.
src/Websocket/Middleware/Authenticate.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
     {
40 40
         try {
41 41
             if ($user = $this->auth->authenticate()) {
42
-                $request->setUserResolver(function () use ($user) {
42
+                $request->setUserResolver(function() use ($user) {
43 43
                     return $user;
44 44
                 });
45 45
             }
Please login to merge, or discard this patch.