Completed
Pull Request — master (#230)
by Albert
04:30
created
src/Concerns/InteractsWithWebsocket.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
             // enable sandbox
66 66
             $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
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
      */
130 130
     public function onClose($server, $fd, $reactorId)
131 131
     {
132
-        if (! $this->isServerWebsocket($fd) || ! $server instanceof Websocket) {
132
+        if (!$this->isServerWebsocket($fd) || !$server instanceof Websocket) {
133 133
             return;
134 134
         }
135 135
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
      */
158 158
     protected function isWebsocketPushPacket($packet)
159 159
     {
160
-        if (! is_array($packet)) {
160
+        if (!is_array($packet)) {
161 161
             return false;
162 162
         }
163 163
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
     {
243 243
         $handlerClass = $this->container->make('config')->get('swoole_websocket.handler');
244 244
 
245
-        if (! $handlerClass) {
245
+        if (!$handlerClass) {
246 246
             throw new WebsocketNotSetInConfigException;
247 247
         }
248 248
 
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
      */
290 290
     protected function bindRoom(): void
291 291
     {
292
-        $this->app->singleton(RoomContract::class, function (Container $container) {
292
+        $this->app->singleton(RoomContract::class, function(Container $container) {
293 293
             $config = $container->make('config');
294 294
             $driver = $config->get('swoole_websocket.default');
295 295
             $settings = $config->get("swoole_websocket.settings.{$driver}");
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
      */
311 311
     protected function bindWebsocket()
312 312
     {
313
-        $this->app->singleton(Websocket::class, function (Container $app) {
313
+        $this->app->singleton(Websocket::class, function(Container $app) {
314 314
             return new Websocket($app->make(RoomContract::class), new Pipeline($app));
315 315
         });
316 316
 
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
         $routePath = $this->container->make('config')
326 326
             ->get('swoole_websocket.route_file');
327 327
 
328
-        if (! file_exists($routePath)) {
328
+        if (!file_exists($routePath)) {
329 329
             $routePath = __DIR__ . '/../../routes/websocket.php';
330 330
         }
331 331
 
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
      */
342 342
     public function isWebsocketPushPayload($payload): bool
343 343
     {
344
-        if (! is_array($payload)) {
344
+        if (!is_array($payload)) {
345 345
             return false;
346 346
         }
347 347
 
Please login to merge, or discard this patch.
src/Websocket/Pusher.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
      */
210 210
     public function shouldBroadcast(): bool
211 211
     {
212
-        return $this->broadcast && empty($this->descriptors) && ! $this->assigned;
212
+        return $this->broadcast && empty($this->descriptors) && !$this->assigned;
213 213
     }
214 214
 
215 215
     /**
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
      */
234 234
     protected function getWebsocketConnections(): array
235 235
     {
236
-        return array_filter(iterator_to_array($this->server->connections), function ($fd) {
236
+        return array_filter(iterator_to_array($this->server->connections), function($fd) {
237 237
             return $this->isServerWebsocket($fd);
238 238
         });
239 239
     }
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
     public function push($payload): void
260 260
     {
261 261
         // attach sender if not broadcast
262
-        if (! $this->broadcast && $this->sender && ! $this->hasDescriptor($this->sender)) {
262
+        if (!$this->broadcast && $this->sender && !$this->hasDescriptor($this->sender)) {
263 263
             $this->addDescriptor($this->sender);
264 264
         }
265 265
 
Please login to merge, or discard this patch.
src/Server/Manager.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
     {
123 123
         foreach ($this->events as $event) {
124 124
             $listener = Str::camel("on_$event");
125
-            $callback = method_exists($this, $listener) ? [$this, $listener] : function () use ($event) {
125
+            $callback = method_exists($this, $listener) ? [$this, $listener] : function() use ($event) {
126 126
                 $this->container->make('events')->dispatch("swoole.$event", func_get_args());
127 127
             };
128 128
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
      */
320 320
     protected function bindSandbox()
321 321
     {
322
-        $this->app->singleton(Sandbox::class, function ($app) {
322
+        $this->app->singleton(Sandbox::class, function($app) {
323 323
             return new Sandbox($app, $this->framework);
324 324
         });
325 325
 
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
      */
441 441
     protected function normalizeException(Throwable $e)
442 442
     {
443
-        if (! $e instanceof Exception) {
443
+        if (!$e instanceof Exception) {
444 444
             $e = new FatalThrowableError($e);
445 445
         }
446 446
 
Please login to merge, or discard this patch.
src/HttpServiceProvider.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
         $options = $config->get('swoole_http.server.options');
145 145
 
146 146
         // only enable task worker in websocket mode and for queue driver
147
-        if ($config->get('queue.default') !== 'swoole' && ! $this->isWebsocket) {
147
+        if ($config->get('queue.default') !== 'swoole' && !$this->isWebsocket) {
148 148
             unset($config['task_worker_num']);
149 149
         }
150 150
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
      */
159 159
     protected function registerServer()
160 160
     {
161
-        $this->app->singleton(Server::class, function () {
161
+        $this->app->singleton(Server::class, function() {
162 162
             if (is_null(static::$server)) {
163 163
                 $this->createSwooleServer();
164 164
                 $this->configureSwooleServer();
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
      */
175 175
     protected function registerDatabaseDriver()
176 176
     {
177
-        $this->app->extend(DatabaseManager::class, function (DatabaseManager $db) {
178
-            $db->extend('mysql-coroutine', function ($config, $name) {
177
+        $this->app->extend(DatabaseManager::class, function(DatabaseManager $db) {
178
+            $db->extend('mysql-coroutine', function($config, $name) {
179 179
                 $config['name'] = $name;
180 180
 
181 181
                 $connection = new MySqlConnection(
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
      */
219 219
     protected function registerSwooleQueueDriver()
220 220
     {
221
-        $this->app->afterResolving('queue', function (QueueManager $manager) {
222
-            $manager->addConnector('swoole', function () {
221
+        $this->app->afterResolving('queue', function(QueueManager $manager) {
222
+            $manager->addConnector('swoole', function() {
223 223
                 return new SwooleTaskConnector($this->app->make(Server::class));
224 224
             });
225 225
         });
Please login to merge, or discard this patch.