Passed
Push — 6.0 ( 1d1725...1d34ad )
by liu
25:26 queued 10:36
created
src/think/route/Url.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 // +----------------------------------------------------------------------
9 9
 // | Author: liu21st <[email protected]>
10 10
 // +----------------------------------------------------------------------
11
-declare (strict_types = 1);
11
+declare(strict_types=1);
12 12
 
13 13
 namespace think\route;
14 14
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
                 }
191 191
             }
192 192
         } elseif (false === strpos($domain, '.') && 0 !== strpos($domain, $rootDomain)) {
193
-            $domain .= '.' . $rootDomain;
193
+            $domain .= '.'.$rootDomain;
194 194
         }
195 195
 
196 196
         if (false !== strpos($domain, '://')) {
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
             $scheme = $this->https || $request->isSsl() ? 'https://' : 'http://';
200 200
         }
201 201
 
202
-        return $scheme . $domain;
202
+        return $scheme.$domain;
203 203
     }
204 204
 
205 205
     /**
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
             }
219 219
         }
220 220
 
221
-        return (empty($suffix) || 0 === strpos($suffix, '.')) ? (string) $suffix : '.' . $suffix;
221
+        return (empty($suffix) || 0 === strpos($suffix, '.')) ? (string) $suffix : '.'.$suffix;
222 222
     }
223 223
 
224 224
     /**
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
             // 解析到控制器
243 243
             $url = substr($url, 1);
244 244
         } elseif ('' === $url) {
245
-            $url = $request->controller() . '/' . $request->action();
245
+            $url = $request->controller().'/'.$request->action();
246 246
         } else {
247 247
             $controller = $request->controller();
248 248
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
             $action     = array_pop($path);
251 251
             $controller = empty($path) ? $controller : array_pop($path);
252 252
 
253
-            $url = $controller . '/' . $action;
253
+            $url = $controller.'/'.$action;
254 254
         }
255 255
 
256 256
         return $url;
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
     {
298 298
         $request = $this->app->request;
299 299
         if (is_string($allowDomain) && false === strpos($allowDomain, '.')) {
300
-            $allowDomain .= '.' . $request->rootDomain();
300
+            $allowDomain .= '.'.$request->rootDomain();
301 301
         }
302 302
         $port = $request->port();
303 303
 
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
             }
317 317
 
318 318
             if ($port && !in_array($port, [80, 443])) {
319
-                $domain .= ':' . $port;
319
+                $domain .= ':'.$port;
320 320
             }
321 321
 
322 322
             if (empty($pattern)) {
@@ -328,12 +328,12 @@  discard block
 block discarded – undo
328 328
 
329 329
             foreach ($pattern as $key => $val) {
330 330
                 if (isset($vars[$key])) {
331
-                    $url    = str_replace(['[:' . $key . ']', '<' . $key . '?>', ':' . $key, '<' . $key . '>'], $type ? $vars[$key] : urlencode((string) $vars[$key]), $url);
331
+                    $url    = str_replace(['[:'.$key.']', '<'.$key.'?>', ':'.$key, '<'.$key.'>'], $type ? $vars[$key] : urlencode((string) $vars[$key]), $url);
332 332
                     $keys[] = $key;
333 333
                     $url    = str_replace(['/?', '-?'], ['/', '-'], $url);
334 334
                     $result = [rtrim($url, '?/-'), $domain, $suffix];
335 335
                 } elseif (2 == $val) {
336
-                    $url    = str_replace(['/[:' . $key . ']', '[:' . $key . ']', '<' . $key . '?>'], '', $url);
336
+                    $url    = str_replace(['/[:'.$key.']', '[:'.$key.']', '<'.$key.'?>'], '', $url);
337 337
                     $url    = str_replace(['/?', '-?'], ['/', '-'], $url);
338 338
                     $result = [rtrim($url, '?/-'), $domain, $suffix];
339 339
                 } else {
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
         if (0 === strpos($url, '[') && $pos = strpos($url, ']')) {
366 366
             // [name] 表示使用路由命名标识生成URL
367 367
             $name = substr($url, 1, $pos - 1);
368
-            $url  = 'name' . substr($url, $pos + 1);
368
+            $url  = 'name'.substr($url, $pos + 1);
369 369
         }
370 370
 
371 371
         if (false === strpos($url, '://') && 0 !== strpos($url, '/')) {
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
         }
393 393
 
394 394
         if ($url) {
395
-            $checkName   = isset($name) ? $name : $url . (isset($info['query']) ? '?' . $info['query'] : '');
395
+            $checkName   = isset($name) ? $name : $url.(isset($info['query']) ? '?'.$info['query'] : '');
396 396
             $checkDomain = $domain && is_string($domain) ? $domain : null;
397 397
 
398 398
             $rule = $this->route->getName($checkName, $checkDomain);
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
                 $suffix = $match[2];
419 419
             }
420 420
         } elseif (!empty($rule) && isset($name)) {
421
-            throw new \InvalidArgumentException('route name not exists:' . $name);
421
+            throw new \InvalidArgumentException('route name not exists:'.$name);
422 422
         } else {
423 423
             // 检测URL绑定
424 424
             $bind = $this->route->getDomainBind($domain && is_string($domain) ? $domain : null);
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
             $file = str_replace('\\', '/', dirname($file));
457 457
         }
458 458
 
459
-        $url = rtrim($file, '/') . '/' . $url;
459
+        $url = rtrim($file, '/').'/'.$url;
460 460
 
461 461
         // URL后缀
462 462
         if ('/' == substr($url, -1) || '' == $url) {
@@ -466,33 +466,33 @@  discard block
 block discarded – undo
466 466
         }
467 467
 
468 468
         // 锚点
469
-        $anchor = !empty($anchor) ? '#' . $anchor : '';
469
+        $anchor = !empty($anchor) ? '#'.$anchor : '';
470 470
 
471 471
         // 参数组装
472 472
         if (!empty($vars)) {
473 473
             // 添加参数
474 474
             if ($this->route->config('url_common_param')) {
475 475
                 $vars = http_build_query($vars);
476
-                $url .= $suffix . '?' . $vars . $anchor;
476
+                $url .= $suffix.'?'.$vars.$anchor;
477 477
             } else {
478 478
                 foreach ($vars as $var => $val) {
479 479
                     $val = (string) $val;
480 480
                     if ('' !== $val) {
481
-                        $url .= $depr . $var . $depr . urlencode($val);
481
+                        $url .= $depr.$var.$depr.urlencode($val);
482 482
                     }
483 483
                 }
484 484
 
485
-                $url .= $suffix . $anchor;
485
+                $url .= $suffix.$anchor;
486 486
             }
487 487
         } else {
488
-            $url .= $suffix . $anchor;
488
+            $url .= $suffix.$anchor;
489 489
         }
490 490
 
491 491
         // 检测域名
492 492
         $domain = $this->parseDomain($url, $domain);
493 493
 
494 494
         // URL组装
495
-        return $domain . rtrim($this->root, '/') . '/' . ltrim($url, '/');
495
+        return $domain.rtrim($this->root, '/').'/'.ltrim($url, '/');
496 496
     }
497 497
 
498 498
     public function __toString()
Please login to merge, or discard this patch.