Passed
Push — master ( 3c1ae9...a3b5d5 )
by Biao
11:40
created
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.
src/Components/HttpClient/SimpleHttpTrait.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
             $parts = parse_url($url);
32 32
             $path = isset($parts['path']) ? $parts['path'] : '/';
33 33
             if (isset($parts['query'])) {
34
-                $path .= '?' . $parts['query'];
34
+                $path .= '?'.$parts['query'];
35 35
             }
36 36
             if (isset($parts['fragment'])) {
37
-                $path .= '#' . $parts['fragment'];
37
+                $path .= '#'.$parts['fragment'];
38 38
             }
39 39
             $client = new CoroutineClient($parts['host'], isset($parts['port']) ? $parts['port'] : 80, isset($parts['scheme']) && $parts['scheme'] === 'https');
40 40
             if (isset($options['timeout'])) {
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
                 continue;
91 91
             }
92 92
             if (isset($headers[$key])) {
93
-                $headers[$key] = (array)$headers[$key];
93
+                $headers[$key] = (array) $headers[$key];
94 94
                 $headers[$key][] = isset($middle[1]) ? trim($middle[1]) : '';
95 95
             } else {
96 96
                 $headers[$key] = isset($middle[1]) ? trim($middle[1]) : '';
Please login to merge, or discard this patch.
src/Swoole/Request.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
                 $server[$headerServerMapping[$key]] = $value;
52 52
             } else {
53 53
                 $key = str_replace('-', '_', $key);
54
-                $server['http_' . $key] = $value;
54
+                $server['http_'.$key] = $value;
55 55
             }
56 56
         }
57 57
         $server = array_change_key_case($server, CASE_UPPER);
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
             && isset($_SERVER['QUERY_STRING'])
66 66
             && $_SERVER['QUERY_STRING'] !== ''
67 67
         ) {
68
-            $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
68
+            $_SERVER['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
69 69
         }
70 70
 
71 71
         // Fix argv & argc
Please login to merge, or discard this patch.
src/Illuminate/Laravel.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
         self::autoload($this->conf['root_path']);
83 83
 
84 84
         // Make kernel for Laravel
85
-        $app = require $this->conf['root_path'] . '/bootstrap/app.php';
85
+        $app = require $this->conf['root_path'].'/bootstrap/app.php';
86 86
         $kernel = $this->conf['is_lumen'] ? null : $app->make(HttpKernel::class);
87 87
 
88 88
         // Boot
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
     {
103 103
         $cfgPaths = [
104 104
             // Framework default configuration
105
-            $this->conf['root_path'] . '/vendor/laravel/lumen-framework/config/',
105
+            $this->conf['root_path'].'/vendor/laravel/lumen-framework/config/',
106 106
             // App configuration
107
-            $this->conf['root_path'] . '/config/',
107
+            $this->conf['root_path'].'/config/',
108 108
         ];
109 109
 
110 110
         $keys = [];
111 111
         foreach ($cfgPaths as $cfgPath) {
112
-            $configs = (array)glob($cfgPath . '*.php');
112
+            $configs = (array) glob($cfgPath.'*.php');
113 113
             foreach ($configs as $config) {
114 114
                 $config = substr(basename($config), 0, -4);
115 115
                 $keys[$config] = $config;
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
 
124 124
     public static function autoload($rootPath)
125 125
     {
126
-        $autoload = $rootPath . '/bootstrap/autoload.php';
126
+        $autoload = $rootPath.'/bootstrap/autoload.php';
127 127
         if (file_exists($autoload)) {
128 128
             require_once $autoload;
129 129
         } else {
130
-            require_once $rootPath . '/vendor/autoload.php';
130
+            require_once $rootPath.'/vendor/autoload.php';
131 131
         }
132 132
     }
133 133
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
         }
157 157
 
158 158
         // prefer content in response, secondly ob
159
-        if (!($response instanceof StreamedResponse) && (string)$content === '' && ob_get_length() > 0) {
159
+        if (!($response instanceof StreamedResponse) && (string) $content === '' && ob_get_length() > 0) {
160 160
             $response->setContent(ob_get_contents());
161 161
         }
162 162
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
         }
174 174
         $uri = urldecode($uri);
175 175
 
176
-        $requestFile = $this->conf['static_path'] . $uri;
176
+        $requestFile = $this->conf['static_path'].$uri;
177 177
         if (is_file($requestFile)) {
178 178
             return $this->createStaticResponse($requestFile, $request);
179 179
         }
@@ -189,9 +189,9 @@  discard block
 block discarded – undo
189 189
 
190 190
     protected function lookupIndex($folder)
191 191
     {
192
-        $folder = rtrim($folder, '/') . '/';
192
+        $folder = rtrim($folder, '/').'/';
193 193
         foreach (self::$staticIndexList as $index) {
194
-            $tmpFile = $folder . $index;
194
+            $tmpFile = $folder.$index;
195 195
             if (is_file($tmpFile)) {
196 196
                 return $tmpFile;
197 197
             }
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 
233 233
     public function bindSwoole($swoole)
234 234
     {
235
-        $this->currentApp->singleton('swoole', function () use ($swoole) {
235
+        $this->currentApp->singleton('swoole', function() use ($swoole) {
236 236
             return $swoole;
237 237
         });
238 238
     }
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
                     Portal::runLaravelSCommand($laravelConf['root_path'], 'reload');
34 34
                     if ($log) {
35 35
                         $action = 'file:';
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
         }
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
                 continue;
27 27
             }
28 28
             $processClass = $item['class'];
29
-            $restartInterval = isset($item['restart_interval']) ? (int)$item['restart_interval'] : 5;
30
-            $callback = function (Process $worker) use ($pidfile, $swoole, $processPrefix, $processClass, $restartInterval, $name, $laravelConfig) {
31
-                file_put_contents($pidfile, $worker->pid . "\n", FILE_APPEND | LOCK_EX);
29
+            $restartInterval = isset($item['restart_interval']) ? (int) $item['restart_interval'] : 5;
30
+            $callback = function(Process $worker) use ($pidfile, $swoole, $processPrefix, $processClass, $restartInterval, $name, $laravelConfig) {
31
+                file_put_contents($pidfile, $worker->pid."\n", FILE_APPEND | LOCK_EX);
32 32
                 $this->initLaravel($laravelConfig, $swoole);
33 33
                 if (!isset(class_implements($processClass)[CustomProcessInterface::class])) {
34 34
                     throw new \InvalidArgumentException(
@@ -42,13 +42,13 @@  discard block
 block discarded – undo
42 42
                 /**@var CustomProcessInterface $processClass */
43 43
                 $this->setProcessTitle(sprintf('%s laravels: %s process', $processPrefix, $name));
44 44
 
45
-                Process::signal(SIGUSR1, function ($signo) use ($name, $processClass, $worker, $pidfile, $swoole) {
45
+                Process::signal(SIGUSR1, function($signo) use ($name, $processClass, $worker, $pidfile, $swoole) {
46 46
                     $this->info(sprintf('Reloading %s process[PID=%d].', $name, $worker->pid));
47 47
                     $processClass::onReload($swoole, $worker);
48 48
                 });
49 49
 
50 50
                 if (method_exists($processClass, 'onStop')) {
51
-                    Process::signal(SIGTERM, function ($signo) use ($name, $processClass, $worker, $pidfile, $swoole) {
51
+                    Process::signal(SIGTERM, function($signo) use ($name, $processClass, $worker, $pidfile, $swoole) {
52 52
                         $this->info(sprintf('Stopping %s process[PID=%d].', $name, $worker->pid));
53 53
                         $processClass::onStop($swoole, $worker);
54 54
                     });
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                 for ($i = 0; $i < $item['num']; $i++) {
73 73
                     $process = $this->makeProcess($callback, $item);
74 74
                     $swoole->addProcess($process);
75
-                    $processList[$name . $i] = $process;
75
+                    $processList[$name.$i] = $process;
76 76
                 }
77 77
             } else {  // For single process
78 78
                 $process = $this->makeProcess($callback, $item);
Please login to merge, or discard this patch.
src/Components/Apollo/Client.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -41,10 +41,10 @@  discard block
 block discarded – undo
41 41
             $this->clientIp = current(swoole_get_local_ip()) ?: gethostname();
42 42
         }
43 43
         if (isset($settings['pull_timeout'])) {
44
-            $this->pullTimeout = (int)$settings['pull_timeout'];
44
+            $this->pullTimeout = (int) $settings['pull_timeout'];
45 45
         }
46 46
         if (isset($settings['backup_old_env'])) {
47
-            $this->backupOldEnv = (bool)$settings['backup_old_env'];
47
+            $this->backupOldEnv = (bool) $settings['backup_old_env'];
48 48
         }
49 49
     }
50 50
 
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
         $settings = [
74 74
             'server'         => getenv('APOLLO_SERVER'),
75 75
             'app_id'         => getenv('APOLLO_APP_ID'),
76
-            'cluster'        => ($cluster = (string)getenv('APOLLO_CLUSTER')) !== '' ? $cluster : null,
77
-            'namespaces'     => ($namespaces = (string)getenv('APOLLO_NAMESPACES')) !== '' ? explode(',', $namespaces) : null,
78
-            'client_ip'      => ($clientIp = (string)getenv('APOLLO_CLIENT_IP')) !== '' ? $clientIp : null,
79
-            'pull_timeout'   => ($pullTimeout = (int)getenv('APOLLO_PULL_TIMEOUT')) > 0 ? $pullTimeout : null,
80
-            'backup_old_env' => ($backupOldEnv = (bool)getenv('APOLLO_BACKUP_OLD_ENV')) ? $backupOldEnv : null,
76
+            'cluster'        => ($cluster = (string) getenv('APOLLO_CLUSTER')) !== '' ? $cluster : null,
77
+            'namespaces'     => ($namespaces = (string) getenv('APOLLO_NAMESPACES')) !== '' ? explode(',', $namespaces) : null,
78
+            'client_ip'      => ($clientIp = (string) getenv('APOLLO_CLIENT_IP')) !== '' ? $clientIp : null,
79
+            'pull_timeout'   => ($pullTimeout = (int) getenv('APOLLO_PULL_TIMEOUT')) > 0 ? $pullTimeout : null,
80
+            'backup_old_env' => ($backupOldEnv = (bool) getenv('APOLLO_BACKUP_OLD_ENV')) ? $backupOldEnv : null,
81 81
         ];
82 82
         return new static($settings);
83 83
     }
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
             'cluster'        => isset($options['apollo-cluster']) && $options['apollo-cluster'] !== '' ? $options['apollo-cluster'] : null,
94 94
             'namespaces'     => !empty($options['apollo-namespaces']) ? $options['apollo-namespaces'] : null,
95 95
             'client_ip'      => isset($options['apollo-client-ip']) && $options['apollo-client-ip'] !== '' ? $options['apollo-client-ip'] : null,
96
-            'pull_timeout'   => isset($options['apollo-pull-timeout']) ? (int)$options['apollo-pull-timeout'] : null,
97
-            'backup_old_env' => isset($options['apollo-backup-old-env']) ? (bool)$options['apollo-backup-old-env'] : null,
96
+            'pull_timeout'   => isset($options['apollo-pull-timeout']) ? (int) $options['apollo-pull-timeout'] : null,
97
+            'backup_old_env' => isset($options['apollo-backup-old-env']) ? (bool) $options['apollo-backup-old-env'] : null,
98 98
         ];
99 99
         return new static($settings);
100 100
     }
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         $configs = [];
117 117
         $uri = sprintf('%s/configs/%s/%s/', $this->server, $this->appId, $this->cluster);
118 118
         foreach ($namespaces as $namespace) {
119
-            $url = $uri . $namespace . '?' . http_build_query([
119
+            $url = $uri.$namespace.'?'.http_build_query([
120 120
                     'releaseKey' => $withReleaseKey && isset($this->releaseKeys[$namespace]) ? $this->releaseKeys[$namespace] : null,
121 121
                     'ip'         => $this->clientIp,
122 122
                 ]);
@@ -146,11 +146,11 @@  discard block
 block discarded – undo
146 146
         $all = $this->pullAll(false, $options);
147 147
         if (count($all) !== count($this->namespaces)) {
148 148
             $lackNamespaces = array_diff($this->namespaces, array_keys($all));
149
-            throw new \RuntimeException('Missing Apollo configurations for namespaces ' . implode(',', $lackNamespaces));
149
+            throw new \RuntimeException('Missing Apollo configurations for namespaces '.implode(',', $lackNamespaces));
150 150
         }
151 151
         $configs = [];
152 152
         foreach ($all as $namespace => $config) {
153
-            $configs[] = '# Namespace: ' . $config['namespaceName'];
153
+            $configs[] = '# Namespace: '.$config['namespaceName'];
154 154
             ksort($config['configurations']);
155 155
             foreach ($config['configurations'] as $key => $value) {
156 156
                 $configs[] = sprintf('%s=%s', $key, $value);
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
             throw new \RuntimeException('Empty Apollo configuration list');
161 161
         }
162 162
         if ($this->backupOldEnv && file_exists($filepath)) {
163
-            rename($filepath, $filepath . '.' . date('YmdHis'));
163
+            rename($filepath, $filepath.'.'.date('YmdHis'));
164 164
         }
165 165
         $fileContent = implode(PHP_EOL, $configs);
166 166
         if (Context::inCoroutine()) {
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
                 if (!empty($this->notifications) && current($this->notifications)['notificationId'] !== -1) { // Ignore the first pull
201 201
                     $callback($notifications);
202 202
                 }
203
-                array_walk($notifications, function (&$notification) {
203
+                array_walk($notifications, function(&$notification) {
204 204
                     unset($notification['messages']);
205 205
                 });
206 206
                 $this->notifications = array_merge($this->notifications, array_column($notifications, null, 'namespaceName'));
Please login to merge, or discard this patch.
src/Components/Prometheus/Exporter.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
                 'value' => $apcSmaInfo['avail_mem'],
31 31
             ],
32 32
         ];
33
-        foreach (new \APCuIterator('/^' . $this->config['apcu_key_prefix'] . $this->config['apcu_key_separator'] . '/') as $item) {
33
+        foreach (new \APCuIterator('/^'.$this->config['apcu_key_prefix'].$this->config['apcu_key_separator'].'/') as $item) {
34 34
             $parts = explode($this->config['apcu_key_separator'], $item['key']);
35 35
             parse_str($parts[3], $labels);
36 36
             if (is_array($item['value'])) {
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
         $metrics = $this->getMetrics();
63 63
         $lines = [];
64 64
         foreach ($metrics as $metric) {
65
-            $lines[] = "# HELP " . $metric['name'] . " {$metric['help']}";
66
-            $lines[] = "# TYPE " . $metric['name'] . " {$metric['type']}";
65
+            $lines[] = "# HELP ".$metric['name']." {$metric['help']}";
66
+            $lines[] = "# TYPE ".$metric['name']." {$metric['type']}";
67 67
 
68 68
             $metricLabels = isset($metric['labels']) ? $metric['labels'] : [];
69 69
             $labels = ['{'];
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
             }
74 74
             $labels[] = '}';
75 75
             $labelStr = implode('', $labels);
76
-            $lines[] = $metric['name'] . "$labelStr {$metric['value']}";
76
+            $lines[] = $metric['name']."$labelStr {$metric['value']}";
77 77
         }
78 78
         return implode("\n", $lines);
79 79
     }
Please login to merge, or discard this patch.
src/Components/Prometheus/CollectorProcess.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
                 'class'    => static::class,
22 22
                 'redirect' => false,
23 23
                 'pipe'     => 0,
24
-                'enable'   => (bool)config('prometheus.enable', true),
24
+                'enable'   => (bool) config('prometheus.enable', true),
25 25
             ],
26 26
         ];
27 27
     }
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
         $taskWorkerNum = isset($swoole->setting['task_worker_num']) ? $swoole->setting['task_worker_num'] : 0;
39 39
         $totalNum = $workerNum + $taskWorkerNum - 1;
40 40
         $workerIds = range(0, $totalNum);
41
-        $runJob = function () use ($swoole, $workerIds, $processCollector, $swooleStatsCollector, $systemCollector) {
41
+        $runJob = function() use ($swoole, $workerIds, $processCollector, $swooleStatsCollector, $systemCollector) {
42 42
             // Collect the metrics of Swoole stats()
43 43
             $swooleStatsCollector->collect();
44 44
 
Please login to merge, or discard this patch.