Completed
Branch feature/coroutine_feature (d624ea)
by Albert
02:17
created
routes/websocket.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,15 +12,15 @@
 block discarded – undo
12 12
 |
13 13
 */
14 14
 
15
-Websocket::on('connect', function ($websocket, Request $request) {
15
+Websocket::on('connect', function($websocket, Request $request) {
16 16
     // called while socket on connect
17 17
 });
18 18
 
19
-Websocket::on('disconnect', function ($websocket) {
19
+Websocket::on('disconnect', function($websocket) {
20 20
     // called while socket on disconnect
21 21
 });
22 22
 
23
-Websocket::on('example', function ($websocket, $data) {
23
+Websocket::on('example', function($websocket, $data) {
24 24
     $websocket->emit('message', $data);
25 25
 });
26 26
 
Please login to merge, or discard this patch.
routes/laravel_routes.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 |
12 12
 */
13 13
 
14
-Route::group(['namespace' => 'SwooleTW\Http\Controllers'], function () {
14
+Route::group(['namespace' => 'SwooleTW\Http\Controllers'], function() {
15 15
     Route::get('socket.io', 'SocketIOController@upgrade');
16 16
     Route::post('socket.io', 'SocketIOController@reject');
17 17
 });
Please login to merge, or discard this patch.
src/Concerns/ResetApplication.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      */
29 29
     protected function rebindProviderContainer($provider, $app)
30 30
     {
31
-        $closure = function () use ($app) {
31
+        $closure = function() use ($app) {
32 32
             $this->app = $app;
33 33
         };
34 34
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
         if ($this->isLaravel()) {
78 78
             $router = $app->make('router');
79 79
             $request = $this->getRequest();
80
-            $closure = function () use ($app, $request) {
80
+            $closure = function() use ($app, $request) {
81 81
                 $this->container = $app;
82 82
                 if (is_null($request)) {
83 83
                     return;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
     {
113 113
         $view = $app->make('view');
114 114
 
115
-        $closure = function () use ($app) {
115
+        $closure = function() use ($app) {
116 116
             $this->container = $app;
117 117
             $this->shared['app'] = $app;
118 118
         };
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
         if ($this->isLaravel()) {
130 130
             $kernel = $app->make(Kernel::class);
131 131
 
132
-            $closure = function () use ($app) {
132
+            $closure = function() use ($app) {
133 133
                 $this->app = $app;
134 134
             };
135 135
 
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
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
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
 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 \Exception(sprintf('Not support framework "%s".', $framework));
113 113
         }
114 114
 
Please login to merge, or discard this patch.
src/Concerns/InteractsWithWebsocket.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Concerns/InteractsWithSwooleTable.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
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');
Please login to merge, or discard this patch.
src/Server/Manager.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
     }
123 123
 
124 124
     /**
125
-      * The listener of "managerStart" event.
126
-      *
127
-      * @return void
128
-      */
125
+     * The listener of "managerStart" event.
126
+     *
127
+     * @return void
128
+     */
129 129
     public function onManagerStart()
130 130
     {
131 131
         $this->setProcessName('manager process');
@@ -357,21 +357,21 @@  discard block
 block discarded – undo
357 357
         swoole_set_process_name($name);
358 358
     }
359 359
 
360
-   /**
361
-    * Indicates if the process is running in macOS.
362
-    *
363
-    * @return bool
364
-    */
360
+    /**
361
+     * Indicates if the process is running in macOS.
362
+     *
363
+     * @return bool
364
+     */
365 365
     protected function isMacOS()
366 366
     {
367 367
         return PHP_OS === 'Darwin';
368 368
     }
369 369
 
370
-   /**
371
-    * Indicates if it's in phpunit environment.
372
-    *
373
-    * @return bool
374
-    */
370
+    /**
371
+     * Indicates if it's in phpunit environment.
372
+     *
373
+     * @return bool
374
+     */
375 375
     protected function isInTesting()
376 376
     {
377 377
         return defined('IN_PHPUNIT') && IN_PHPUNIT;
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
             if (method_exists($this, $listener)) {
102 102
                 $this->container['swoole.server']->on($event, [$this, $listener]);
103 103
             } else {
104
-                $this->container['swoole.server']->on($event, function () use ($event) {
104
+                $this->container['swoole.server']->on($event, function() use ($event) {
105 105
                     $event = sprintf('swoole.%s', $event);
106 106
 
107 107
                     $this->container['events']->fire($event, func_get_args());
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
      */
275 275
     protected function bindSwooleServer()
276 276
     {
277
-        $this->app->singleton(Server::class, function ($app) {
277
+        $this->app->singleton(Server::class, function($app) {
278 278
             return $this->container['swoole.server'];
279 279
         });
280 280
         $this->app->alias(Server::class, 'swoole.server');
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
      */
286 286
     protected function bindSandbox()
287 287
     {
288
-        $this->app->singleton(Sandbox::class, function ($app) {
288
+        $this->app->singleton(Sandbox::class, function($app) {
289 289
             return new Sandbox($app, $this->framework);
290 290
         });
291 291
         $this->app->alias(Sandbox::class, 'swoole.sandbox');
Please login to merge, or discard this patch.
src/Server/Sandbox.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function __construct($app = null, $framework = null)
44 44
     {
45
-        if (! $app instanceof Container) {
45
+        if (!$app instanceof Container) {
46 46
             return;
47 47
         }
48 48
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
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
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
      */
211 211
     public function run(Request $request)
212 212
     {
213
-        if (! $this->getSnapshot() instanceof Container) {
213
+        if (!$this->getSnapshot() instanceof Container) {
214 214
             throw new SandboxException('Sandbox is not enabled.');
215 215
         }
216 216
 
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
             $response->sendContent();
261 261
         } elseif ($response instanceof SymfonyResponse) {
262 262
             $content = $response->getContent();
263
-        } elseif (! $isFile = $response instanceof BinaryFileResponse) {
263
+        } elseif (!$isFile = $response instanceof BinaryFileResponse) {
264 264
             $content = (string) $response;
265 265
         }
266 266
 
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
         $this->terminate($request, $response);
269 269
 
270 270
         // append ob content to response
271
-        if (! $isFile && ob_get_length() > 0) {
271
+        if (!$isFile && ob_get_length() > 0) {
272 272
             if ($isStream) {
273 273
                 $response->output = ob_get_contents();
274 274
             } else {
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
      */
342 342
     public function enable()
343 343
     {
344
-        if (! $this->config instanceof ConfigContract) {
344
+        if (!$this->config instanceof ConfigContract) {
345 345
             throw new SandboxException('Please initialize after setting base app.');
346 346
         }
347 347
 
Please login to merge, or discard this patch.
src/LaravelServiceProvider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.