Passed
Push — master ( 3976f6...00f479 )
by Biao
06:42 queued 04:01
created
src/Swoole/Request.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
                 $server[$headerServerMapping[$key]] = $value;
51 51
             } else {
52 52
                 $key = str_replace('-', '_', $key);
53
-                $server['http_' . $key] = $value;
53
+                $server['http_'.$key] = $value;
54 54
             }
55 55
         }
56 56
         $server = array_change_key_case($server, CASE_UPPER);
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
             && isset($_SERVER['QUERY_STRING'])
65 65
             && strlen($_SERVER['QUERY_STRING']) > 0
66 66
         ) {
67
-            $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
67
+            $_SERVER['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
68 68
         }
69 69
 
70 70
         // Fix argv & argc
Please login to merge, or discard this patch.
src/Swoole/InotifyTrait.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,17 +19,17 @@
 block discarded – undo
19 19
             return false;
20 20
         }
21 21
 
22
-        $fileTypes = isset($config['file_types']) ? (array)$config['file_types'] : [];
22
+        $fileTypes = isset($config['file_types']) ? (array) $config['file_types'] : [];
23 23
         if (empty($fileTypes)) {
24 24
             $this->warning('No file types to watch by inotify');
25 25
             return false;
26 26
         }
27 27
 
28
-        $callback = function () use ($config, $laravelConf) {
28
+        $callback = function() use ($config, $laravelConf) {
29 29
             $log = !empty($config['log']);
30 30
             $this->setProcessTitle(sprintf('%s laravels: inotify process', $config['process_prefix']));
31 31
             $inotify = new Inotify($config['watch_path'], IN_CREATE | IN_DELETE | IN_MODIFY | IN_MOVE,
32
-                function ($event) use ($log, $laravelConf) {
32
+                function($event) use ($log, $laravelConf) {
33 33
                     $reloadCmd = trim(sprintf('%s -c "%s" %s/bin/laravels reload', PHP_BINARY, php_ini_loaded_file(), $laravelConf['root_path']));
34 34
                     Portal::runCommand($reloadCmd);
35 35
                     if ($log) {
Please login to merge, or discard this patch.
src/Swoole/Task/BaseTask.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
         if ($delay < 0) {
29 29
             throw new \InvalidArgumentException('The delay must be greater than or equal to 0');
30 30
         }
31
-        $this->delay = (int)$delay;
31
+        $this->delay = (int) $delay;
32 32
         return $this;
33 33
     }
34 34
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         if ($tries < 1) {
52 52
             throw new \InvalidArgumentException('The number of attempts must be greater than or equal to 1');
53 53
         }
54
-        $this->tries = (int)$tries;
54
+        $this->tries = (int) $tries;
55 55
         return $this;
56 56
     }
57 57
 
@@ -71,19 +71,19 @@  discard block
 block discarded – undo
71 71
      */
72 72
     protected function task($task)
73 73
     {
74
-        $deliver = function () use ($task) {
74
+        $deliver = function() use ($task) {
75 75
             /**@var \Swoole\Http\Server $swoole */
76 76
             $swoole = app('swoole');
77 77
             // The worker_id of timer process is -1
78 78
             if ($swoole->worker_id === -1 || $swoole->taskworker) {
79
-                $taskWorkerNum = isset($swoole->setting['task_worker_num']) ? (int)$swoole->setting['task_worker_num'] : 0;
79
+                $taskWorkerNum = isset($swoole->setting['task_worker_num']) ? (int) $swoole->setting['task_worker_num'] : 0;
80 80
                 if ($taskWorkerNum < 2) {
81 81
                     throw new \InvalidArgumentException('LaravelS: async task needs to set task_worker_num >= 2');
82 82
                 }
83 83
                 $workerNum = isset($swoole->setting['worker_num']) ? $swoole->setting['worker_num'] : 0;
84 84
                 $totalNum = $workerNum + $taskWorkerNum;
85 85
 
86
-                $getAvailableId = function ($startId, $endId, $excludeId) {
86
+                $getAvailableId = function($startId, $endId, $excludeId) {
87 87
                     $ids = range($startId, $endId);
88 88
                     $ids = array_flip($ids);
89 89
                     unset($ids[$excludeId]);
Please login to merge, or discard this patch.
src/Swoole/Process/CustomProcessTrait.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
     public function addCustomProcesses(Server $swoole, $processPrefix, array $processes, array $laravelConfig)
13 13
     {
14
-        $pidfile = dirname($swoole->setting['pid_file']) . '/' . $this->customProcessPidFile;
14
+        $pidfile = dirname($swoole->setting['pid_file']).'/'.$this->customProcessPidFile;
15 15
         if (file_exists($pidfile)) {
16 16
             unlink($pidfile);
17 17
         }
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
                 continue;
30 30
             }
31 31
             $processClass = $item['class'];
32
-            $restartInterval = isset($item['restart_interval']) ? (int)$item['restart_interval'] : 5;
33
-            $callback = function (Process $worker) use ($pidfile, $swoole, $processPrefix, $processClass, $restartInterval, $name, $laravelConfig) {
34
-                file_put_contents($pidfile, $worker->pid . "\n", FILE_APPEND | LOCK_EX);
32
+            $restartInterval = isset($item['restart_interval']) ? (int) $item['restart_interval'] : 5;
33
+            $callback = function(Process $worker) use ($pidfile, $swoole, $processPrefix, $processClass, $restartInterval, $name, $laravelConfig) {
34
+                file_put_contents($pidfile, $worker->pid."\n", FILE_APPEND | LOCK_EX);
35 35
                 $this->initLaravel($laravelConfig, $swoole);
36 36
                 if (!isset(class_implements($processClass)[CustomProcessInterface::class])) {
37 37
                     throw new \InvalidArgumentException(
@@ -45,13 +45,13 @@  discard block
 block discarded – undo
45 45
                 /**@var CustomProcessInterface $processClass */
46 46
                 $this->setProcessTitle(sprintf('%s laravels: %s process', $processPrefix, $name));
47 47
 
48
-                Process::signal(SIGUSR1, function ($signo) use ($name, $processClass, $worker, $pidfile, $swoole) {
48
+                Process::signal(SIGUSR1, function($signo) use ($name, $processClass, $worker, $pidfile, $swoole) {
49 49
                     $this->info(sprintf('Reloading %s process[PID=%d].', $name, $worker->pid));
50 50
                     $processClass::onReload($swoole, $worker);
51 51
                 });
52 52
 
53 53
                 if (method_exists($processClass, 'onStop')) {
54
-                    Process::signal(SIGTERM, function ($signo) use ($name, $processClass, $worker, $pidfile, $swoole) {
54
+                    Process::signal(SIGTERM, function($signo) use ($name, $processClass, $worker, $pidfile, $swoole) {
55 55
                         $this->info(sprintf('Stopping %s process[PID=%d].', $name, $worker->pid));
56 56
                         $processClass::onStop($swoole, $worker);
57 57
                     });
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
                 $coroutineAvailable = class_exists('Swoole\Coroutine');
61 61
                 $coroutineRuntimeAvailable = class_exists('Swoole\Runtime');
62
-                $runProcess = function () use ($name, $processClass, $restartInterval, $swoole, $worker, $coroutineAvailable, $coroutineRuntimeAvailable) {
62
+                $runProcess = function() use ($name, $processClass, $restartInterval, $swoole, $worker, $coroutineAvailable, $coroutineRuntimeAvailable) {
63 63
                     $coroutineRuntimeAvailable && \Swoole\Runtime::enableCoroutine();
64 64
                     $this->callWithCatchException([$processClass, 'callback'], [$swoole, $worker]);
65 65
                     // Avoid frequent process creation
Please login to merge, or discard this patch.
src/Swoole/Timer/TimerTrait.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
             $config['jobs'][] = CheckGlobalTimerAliveCronJob::class;
25 25
         }
26 26
 
27
-        $callback = function (Process $process) use ($swoole, $config, $laravelConfig) {
28
-            $pidfile = dirname($swoole->setting['pid_file']) . '/' . $this->timerPidFile;
27
+        $callback = function(Process $process) use ($swoole, $config, $laravelConfig) {
28
+            $pidfile = dirname($swoole->setting['pid_file']).'/'.$this->timerPidFile;
29 29
             file_put_contents($pidfile, $process->pid);
30 30
             $this->setProcessTitle(sprintf('%s laravels: timer process', $config['process_prefix']));
31 31
             $this->initLaravel($laravelConfig, $swoole);
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 
40 40
             $timerIds = $this->registerTimers($config['jobs']);
41 41
 
42
-            Process::signal(SIGUSR1, function ($signo) use ($config, $timerIds, $process) {
42
+            Process::signal(SIGUSR1, function($signo) use ($config, $timerIds, $process) {
43 43
                 foreach ($timerIds as $timerId) {
44 44
                     if (Timer::exists($timerId)) {
45 45
                         Timer::clear($timerId);
46 46
                     }
47 47
                 }
48
-                Timer::after($config['max_wait_time'] * 1000, function () use ($process) {
48
+                Timer::after($config['max_wait_time'] * 1000, function() use ($process) {
49 49
                     $process->exit(0);
50 50
                 });
51 51
             });
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
             if (empty($job->interval())) {
77 77
                 throw new \InvalidArgumentException(sprintf('The interval of %s cannot be empty', get_class($job)));
78 78
             }
79
-            $runJob = function () use ($job) {
80
-                $runCallback = function () use ($job) {
81
-                    $this->callWithCatchException(function () use ($job) {
79
+            $runJob = function() use ($job) {
80
+                $runCallback = function() use ($job) {
81
+                    $this->callWithCatchException(function() use ($job) {
82 82
                         if (($job instanceof CheckGlobalTimerAliveCronJob) || $job::isEnable()) {
83 83
                             $job->run();
84 84
                         }
Please login to merge, or discard this patch.
src/Console/Portal.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
             if ($value === false) {
132 132
                 continue;
133 133
             }
134
-            $passOptionStr .= sprintf('--%s%s ', $key, is_bool($value) ? '' : ('=' . $value));
134
+            $passOptionStr .= sprintf('--%s%s ', $key, is_bool($value) ? '' : ('='.$value));
135 135
         }
136
-        $statusCode = $this->runArtisanCommand(trim('laravels config ' . $passOptionStr));
136
+        $statusCode = $this->runArtisanCommand(trim('laravels config '.$passOptionStr));
137 137
         if ($statusCode !== 0) {
138 138
             return $statusCode;
139 139
         }
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         $config = $this->getConfig();
143 143
 
144 144
         if (!$config['server']['ignore_check_pid'] && file_exists($config['server']['swoole']['pid_file'])) {
145
-            $pid = (int)file_get_contents($config['server']['swoole']['pid_file']);
145
+            $pid = (int) file_get_contents($config['server']['swoole']['pid_file']);
146 146
             if ($pid > 0 && self::kill($pid, 0)) {
147 147
                 $this->warning(sprintf('Swoole[PID=%d] is already running.', $pid));
148 148
                 return 1;
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
                 $basePath = dirname($pidFile);
189 189
                 $deleteFiles = [
190 190
                     $pidFile,
191
-                    $basePath . '/laravels-custom-processes.pid',
192
-                    $basePath . '/laravels-timer-process.pid',
191
+                    $basePath.'/laravels-custom-processes.pid',
192
+                    $basePath.'/laravels-timer-process.pid',
193 193
                 ];
194 194
                 foreach ($deleteFiles as $deleteFile) {
195 195
                     if (file_exists($deleteFile)) {
@@ -239,9 +239,9 @@  discard block
 block discarded – undo
239 239
         }
240 240
 
241 241
         // Reload custom processes
242
-        $pidFile = dirname($pidFile) . '/laravels-custom-processes.pid';
242
+        $pidFile = dirname($pidFile).'/laravels-custom-processes.pid';
243 243
         if (file_exists($pidFile)) {
244
-            $pids = (array)explode("\n", trim(file_get_contents($pidFile)));
244
+            $pids = (array) explode("\n", trim(file_get_contents($pidFile)));
245 245
             unlink($pidFile);
246 246
             foreach ($pids as $pid) {
247 247
                 if (!$pid || !self::kill($pid, 0)) {
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 
260 260
         // Reload timer process
261 261
         if (!empty($config['server']['timer']['enable']) && !empty($config['server']['timer']['jobs'])) {
262
-            $pidFile = dirname($pidFile) . '/laravels-timer-process.pid';
262
+            $pidFile = dirname($pidFile).'/laravels-timer-process.pid';
263 263
             $pid = file_get_contents($pidFile);
264 264
             if (!$pid || !self::kill($pid, 0)) {
265 265
                 $this->error("Timer process[PID={$pid}] does not exist, or permission denied.");
@@ -283,9 +283,9 @@  discard block
 block discarded – undo
283 283
     public function loadApollo(array $options)
284 284
     {
285 285
         Client::putCommandOptionsToEnv($options);
286
-        $envFile = $this->basePath . '/.env';
286
+        $envFile = $this->basePath.'/.env';
287 287
         if (isset($options['env'])) {
288
-            $envFile .= '.' . $options['env'];
288
+            $envFile .= '.'.$options['env'];
289 289
         }
290 290
         Client::createFromCommandOptions($options)->pullAllAndSave($envFile);
291 291
     }
@@ -306,12 +306,12 @@  discard block
 block discarded – undo
306 306
 
307 307
     public function getConfig()
308 308
     {
309
-        return unserialize((string)file_get_contents($this->getConfPath()));
309
+        return unserialize((string) file_get_contents($this->getConfPath()));
310 310
     }
311 311
 
312 312
     protected function getConfPath()
313 313
     {
314
-        return $this->basePath . '/storage/laravels.conf';
314
+        return $this->basePath.'/storage/laravels.conf';
315 315
     }
316 316
 
317 317
     public static function runCommand($cmd, $input = null)
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
     public static function kill($pid, $sig)
333 333
     {
334 334
         try {
335
-            return Process::kill((int)$pid, $sig);
335
+            return Process::kill((int) $pid, $sig);
336 336
         } catch (\Exception $e) {
337 337
             return false;
338 338
         }
Please login to merge, or discard this patch.
src/Swoole/Timer/RenewGlobalTimerLockCronJob.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
     public function interval()
13 13
     {
14
-        return (int)(static::GLOBAL_TIMER_LOCK_SECONDS * 0.9) * 1000;
14
+        return (int) (static::GLOBAL_TIMER_LOCK_SECONDS * 0.9) * 1000;
15 15
     }
16 16
 
17 17
     public function isImmediate()
Please login to merge, or discard this patch.
src/Swoole/Timer/CronJob.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 
93 93
     public static function getGlobalTimerCacheKey()
94 94
     {
95
-        return 'laravels:timer:' . strtolower(self::$globalTimerLockKey);
95
+        return 'laravels:timer:'.strtolower(self::$globalTimerLockKey);
96 96
     }
97 97
 
98 98
     public static function getGlobalTimerLock()
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
         $expire = self::GLOBAL_TIMER_LOCK_SECONDS;
106 106
         $result = $redis->set($key, $value, 'ex', $expire, 'nx');
107 107
         // Compatible with Predis and PhpRedis
108
-        return $result === true || ((string)$result === 'OK');
108
+        return $result === true || ((string) $result === 'OK');
109 109
     }
110 110
 
111 111
     protected static function getCurrentInstanceId()
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
     {
118 118
         /**@var \Illuminate\Redis\Connections\PhpRedisConnection $redis */
119 119
         $redis = app('redis');
120
-        return (bool)$redis->exists(self::getGlobalTimerCacheKey());
120
+        return (bool) $redis->exists(self::getGlobalTimerCacheKey());
121 121
     }
122 122
 
123 123
     public static function isCurrentTimerAlive()
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
     {
134 134
         /**@var \Illuminate\Redis\Connections\PhpRedisConnection $redis */
135 135
         $redis = app('redis');
136
-        return (bool)$redis->expire(self::getGlobalTimerCacheKey(), $expire);
136
+        return (bool) $redis->expire(self::getGlobalTimerCacheKey(), $expire);
137 137
     }
138 138
 
139 139
     public static function setGlobalTimerLockKey($lockKey)
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 
144 144
     public static function setEnable($enable)
145 145
     {
146
-        self::$enable = (bool)$enable;
146
+        self::$enable = (bool) $enable;
147 147
     }
148 148
 
149 149
     public static function isEnable()
Please login to merge, or discard this patch.
src/Swoole/Timer/CheckGlobalTimerAliveCronJob.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
     public function interval()
13 13
     {
14
-        return (int)(static::GLOBAL_TIMER_LOCK_SECONDS * 0.9) * 1000;
14
+        return (int) (static::GLOBAL_TIMER_LOCK_SECONDS * 0.9) * 1000;
15 15
     }
16 16
 
17 17
     public function isImmediate()
Please login to merge, or discard this patch.