Test Failed
Push — feature/request-max-time-metri... ( d6cce4...c0f683 )
by Biao
09:43 queued 04:47
created
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 \Redis|\RedisCluster|\Predis\Client $redis */
119 119
         $redis = app('redis')->client(); // Fix: Redis exists() always returns false on cluster mode for some older versions of Laravel/Lumen, see https://github.com/illuminate/redis/commit/62ff6a06a9c91902d3baa7feda20bab5e807606f
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\RedisManager $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)
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 
155 155
     public static function setEnable($enable)
156 156
     {
157
-        self::$enable = (bool)$enable;
157
+        self::$enable = (bool) $enable;
158 158
     }
159 159
 
160 160
     public static function isEnable()
Please login to merge, or discard this patch.
src/Illuminate/Laravel.php 1 patch
Spacing   +12 added lines, -12 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
 
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
     public function handleStatic(IlluminateRequest $request)
169 169
     {
170 170
         $uri = $request->getRequestUri();
171
-        $uri = (string)str_replace("\0", '', urldecode($uri));
171
+        $uri = (string) str_replace("\0", '', urldecode($uri));
172 172
         if (isset(self::$staticBlackList[$uri]) || strpos($uri, '/..') !== false) {
173 173
             return false;
174 174
         }
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/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
                 $key = preg_replace('/[^a-zA-Z0-9_.]/', '_', $key);
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
             throw new \RuntimeException('Empty Apollo configuration list');
162 162
         }
163 163
         if ($this->backupOldEnv && file_exists($filepath)) {
164
-            rename($filepath, $filepath . '.' . date('YmdHis'));
164
+            rename($filepath, $filepath.'.'.date('YmdHis'));
165 165
         }
166 166
         $fileContent = implode(PHP_EOL, $configs);
167 167
         if (Context::inCoroutine()) {
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
                 if (!empty($this->notifications) && current($this->notifications)['notificationId'] !== -1) { // Ignore the first pull
202 202
                     $callback($notifications);
203 203
                 }
204
-                array_walk($notifications, function (&$notification) {
204
+                array_walk($notifications, function(&$notification) {
205 205
                     unset($notification['messages']);
206 206
                 });
207 207
                 $this->notifications = array_merge($this->notifications, array_column($notifications, null, 'namespaceName'));
Please login to merge, or discard this patch.
src/Console/Portal.php 1 patch
Spacing   +19 added lines, -19 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 = self::runArtisanCommand($this->basePath, trim('laravels config ' . $passOptionStr));
136
+        $statusCode = self::runArtisanCommand($this->basePath, 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;
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
         $basePath = dirname($pidFile);
195 195
         $deleteFiles = [
196 196
             $pidFile,
197
-            $basePath . '/laravels-custom-processes.pid',
198
-            $basePath . '/laravels-timer-process.pid',
197
+            $basePath.'/laravels-custom-processes.pid',
198
+            $basePath.'/laravels-timer-process.pid',
199 199
         ];
200 200
         foreach ($deleteFiles as $deleteFile) {
201 201
             if (file_exists($deleteFile)) {
@@ -237,9 +237,9 @@  discard block
 block discarded – undo
237 237
         }
238 238
 
239 239
         // Reload custom processes
240
-        $pidFile = dirname($pidFile) . '/laravels-custom-processes.pid';
240
+        $pidFile = dirname($pidFile).'/laravels-custom-processes.pid';
241 241
         if (file_exists($pidFile)) {
242
-            $pids = (array)explode("\n", trim(file_get_contents($pidFile)));
242
+            $pids = (array) explode("\n", trim(file_get_contents($pidFile)));
243 243
             unlink($pidFile);
244 244
             foreach ($pids as $pid) {
245 245
                 if (!$pid || !self::kill($pid, 0)) {
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 
258 258
         // Reload timer process
259 259
         if (!empty($config['server']['timer']['enable']) && !empty($config['server']['timer']['jobs'])) {
260
-            $pidFile = dirname($pidFile) . '/laravels-timer-process.pid';
260
+            $pidFile = dirname($pidFile).'/laravels-timer-process.pid';
261 261
             $pid = file_get_contents($pidFile);
262 262
             if (!$pid || !self::kill($pid, 0)) {
263 263
                 $this->error("Timer process[PID={$pid}] does not exist, or permission denied.");
@@ -281,9 +281,9 @@  discard block
 block discarded – undo
281 281
     public function loadApollo(array $options)
282 282
     {
283 283
         Client::putCommandOptionsToEnv($options);
284
-        $envFile = $this->basePath . '/.env';
284
+        $envFile = $this->basePath.'/.env';
285 285
         if (isset($options['env'])) {
286
-            $envFile .= '.' . $options['env'];
286
+            $envFile .= '.'.$options['env'];
287 287
         }
288 288
         Client::createFromCommandOptions($options)->pullAllAndSave($envFile);
289 289
     }
@@ -311,15 +311,15 @@  discard block
 block discarded – undo
311 311
             $phpCmd = sprintf('%s -c "%s"', PHP_BINARY, $iniFile);
312 312
         }
313 313
 
314
-        $checkSwooleCmd = $phpCmd . ' --ri swoole';
315
-        $checkOpenSwooleCmd = $phpCmd . ' --ri openswoole';
314
+        $checkSwooleCmd = $phpCmd.' --ri swoole';
315
+        $checkOpenSwooleCmd = $phpCmd.' --ri openswoole';
316 316
         // Short-circuit, if Swoole is found Loaded already. If not, check for Open-Swoole as well.
317
-        if (stripos((string)shell_exec($checkSwooleCmd), 'enabled') === false
318
-            && stripos((string)shell_exec($checkOpenSwooleCmd), 'enabled') === false) {
317
+        if (stripos((string) shell_exec($checkSwooleCmd), 'enabled') === false
318
+            && stripos((string) shell_exec($checkOpenSwooleCmd), 'enabled') === false) {
319 319
             $phpCmd .= ' -d "extension=swoole"';
320 320
         }
321 321
 
322
-        return trim($phpCmd . ' ' . $subCmd);
322
+        return trim($phpCmd.' '.$subCmd);
323 323
     }
324 324
 
325 325
     public static function runArtisanCommand($basePath, $cmd)
@@ -336,16 +336,16 @@  discard block
 block discarded – undo
336 336
 
337 337
     public function getConfig()
338 338
     {
339
-        return unserialize((string)file_get_contents($this->getConfigPath()));
339
+        return unserialize((string) file_get_contents($this->getConfigPath()));
340 340
     }
341 341
 
342 342
     protected function getConfigPath()
343 343
     {
344 344
         $storagePath = getenv('APP_STORAGE_PATH');
345 345
         if ($storagePath === false) {
346
-            $storagePath = $this->basePath . '/storage';
346
+            $storagePath = $this->basePath.'/storage';
347 347
         }
348
-        return $storagePath . '/laravels.conf';
348
+        return $storagePath.'/laravels.conf';
349 349
     }
350 350
 
351 351
     public static function runCommand($cmd, $input = null)
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
     public static function kill($pid, $sig)
367 367
     {
368 368
         try {
369
-            return Process::kill((int)$pid, $sig);
369
+            return Process::kill((int) $pid, $sig);
370 370
         } catch (\Exception $e) {
371 371
             return false;
372 372
         }
Please login to merge, or discard this patch.
src/Components/Prometheus/Collectors/HttpRequestCollector.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -21,26 +21,26 @@  discard block
 block discarded – undo
21 21
         if ($routes instanceof \Illuminate\Routing\RouteCollection) { // Laravel
22 22
             foreach ($routes->getRoutes() as $route) {
23 23
                 $method = $route->methods()[0];
24
-                $uri = '/' . ltrim($route->uri(), '/');
25
-                $this->routes[$method . $uri] = $uri;
24
+                $uri = '/'.ltrim($route->uri(), '/');
25
+                $this->routes[$method.$uri] = $uri;
26 26
 
27 27
                 $action = $route->getAction();
28 28
                 if (is_string($action['uses'])) { // Uses
29
-                    $this->routesByUses[$method . $action['uses']] = $uri;
29
+                    $this->routesByUses[$method.$action['uses']] = $uri;
30 30
                 } elseif ($action['uses'] instanceof Closure) {  // Closure
31 31
                     $objectId = spl_object_hash($action['uses']);
32
-                    $this->routesByClosure[$method . $objectId] = $uri;
32
+                    $this->routesByClosure[$method.$objectId] = $uri;
33 33
                 }
34 34
             }
35 35
         } elseif (is_array($routes)) { // Lumen
36 36
             $this->routes = $routes;
37 37
             foreach ($routes as $route) {
38 38
                 if (isset($route['action']['uses'])) { // Uses
39
-                    $this->routesByUses[$route['method'] . $route['action']['uses']] = $route['uri'];
39
+                    $this->routesByUses[$route['method'].$route['action']['uses']] = $route['uri'];
40 40
                 }
41 41
                 if (isset($route['action'][0]) && $route['action'][0] instanceof Closure) { // Closure
42 42
                     $objectId = spl_object_hash($route['action'][0]);
43
-                    $this->routesByClosure[$route['method'] . $objectId] = $route['uri'];
43
+                    $this->routesByClosure[$route['method'].$objectId] = $route['uri'];
44 44
                 }
45 45
             }
46 46
         }
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         }
64 64
 
65 65
         $uri = $this->findRouteUri($request);
66
-        $cost = (int)round((microtime(true) - $request->server('REQUEST_TIME_FLOAT')) * 1000000); // Time unit: μs
66
+        $cost = (int) round((microtime(true) - $request->server('REQUEST_TIME_FLOAT')) * 1000000); // Time unit: μs
67 67
 
68 68
         // Http Request Stats
69 69
         $requestLabels = http_build_query([
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     {
103 103
         $method = $request->getMethod();
104 104
         $uri = $request->getPathInfo();
105
-        $key = $method . $uri;
105
+        $key = $method.$uri;
106 106
         if (isset($this->routes[$key])) {
107 107
             return $uri;
108 108
         }
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
             $uri = $route->uri();
113 113
         } elseif (is_array($route)) { // Lumen
114 114
             if (isset($route[1]['uses'])) {
115
-                $key = $method . $route[1]['uses'];
115
+                $key = $method.$route[1]['uses'];
116 116
                 if (isset($this->routesByUses[$key])) {
117 117
                     $uri = $this->routesByUses[$key];
118 118
                 }
119 119
             } elseif (isset($route[1][0]) && $route[1][0] instanceof Closure) {
120
-                $key = $method . spl_object_hash($route[1][0]);
120
+                $key = $method.spl_object_hash($route[1][0]);
121 121
                 if (isset($this->routesByClosure[$key])) {
122 122
                     $uri = $this->routesByClosure[$key];
123 123
                 }
Please login to merge, or discard this patch.