Passed
Pull Request — 6.0 (#2064)
by
unknown
05:56
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)) {
@@ -327,12 +327,12 @@  discard block
 block discarded – undo
327 327
 
328 328
             foreach ($pattern as $key => $val) {
329 329
                 if (isset($vars[$key])) {
330
-                    $url = str_replace(['[:' . $key . ']', '<' . $key . '?>', ':' . $key, '<' . $key . '>'], $type ? $vars[$key] : urlencode((string) $vars[$key]), $url);
330
+                    $url = str_replace(['[:'.$key.']', '<'.$key.'?>', ':'.$key, '<'.$key.'>'], $type ? $vars[$key] : urlencode((string) $vars[$key]), $url);
331 331
                     unset($vars[$key]);
332 332
                     $url    = str_replace(['/?', '-?'], ['/', '-'], $url);
333 333
                     $result = [rtrim($url, '?/-'), $domain, $suffix];
334 334
                 } elseif (2 == $val) {
335
-                    $url    = str_replace(['/[:' . $key . ']', '[:' . $key . ']', '<' . $key . '?>'], '', $url);
335
+                    $url    = str_replace(['/[:'.$key.']', '[:'.$key.']', '<'.$key.'?>'], '', $url);
336 336
                     $url    = str_replace(['/?', '-?'], ['/', '-'], $url);
337 337
                     $result = [rtrim($url, '?/-'), $domain, $suffix];
338 338
                 } else {
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
         if (0 === strpos($url, '[') && $pos = strpos($url, ']')) {
361 361
             // [name] 表示使用路由命名标识生成URL
362 362
             $name = substr($url, 1, $pos - 1);
363
-            $url  = 'name' . substr($url, $pos + 1);
363
+            $url  = 'name'.substr($url, $pos + 1);
364 364
         }
365 365
 
366 366
         if (false === strpos($url, '://') && 0 !== strpos($url, '/')) {
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
         }
388 388
 
389 389
         if ($url) {
390
-            $checkName   = isset($name) ? $name : $url . (isset($info['query']) ? '?' . $info['query'] : '');
390
+            $checkName   = isset($name) ? $name : $url.(isset($info['query']) ? '?'.$info['query'] : '');
391 391
             $checkDomain = $domain && is_string($domain) ? $domain : null;
392 392
 
393 393
             $rule = $this->route->getName($checkName, $checkDomain);
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
                 $suffix = $match[2];
414 414
             }
415 415
         } elseif (!empty($rule) && isset($name)) {
416
-            throw new \InvalidArgumentException('route name not exists:' . $name);
416
+            throw new \InvalidArgumentException('route name not exists:'.$name);
417 417
         } else {
418 418
             // 检测URL绑定
419 419
             $bind = $this->route->getDomainBind($domain && is_string($domain) ? $domain : null);
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
             $file = str_replace('\\', '/', dirname($file));
452 452
         }
453 453
 
454
-        $url = rtrim($file, '/') . '/' . $url;
454
+        $url = rtrim($file, '/').'/'.$url;
455 455
 
456 456
         // URL后缀
457 457
         if ('/' == substr($url, -1) || '' == $url) {
@@ -461,33 +461,33 @@  discard block
 block discarded – undo
461 461
         }
462 462
 
463 463
         // 锚点
464
-        $anchor = !empty($anchor) ? '#' . $anchor : '';
464
+        $anchor = !empty($anchor) ? '#'.$anchor : '';
465 465
 
466 466
         // 参数组装
467 467
         if (!empty($vars)) {
468 468
             // 添加参数
469 469
             if ($this->route->config('url_common_param')) {
470 470
                 $vars = http_build_query($vars);
471
-                $url .= $suffix . '?' . $vars . $anchor;
471
+                $url .= $suffix.'?'.$vars.$anchor;
472 472
             } else {
473 473
                 foreach ($vars as $var => $val) {
474 474
                     $val = (string) $val;
475 475
                     if ('' !== $val) {
476
-                        $url .= $depr . $var . $depr . urlencode($val);
476
+                        $url .= $depr.$var.$depr.urlencode($val);
477 477
                     }
478 478
                 }
479 479
 
480
-                $url .= $suffix . $anchor;
480
+                $url .= $suffix.$anchor;
481 481
             }
482 482
         } else {
483
-            $url .= $suffix . $anchor;
483
+            $url .= $suffix.$anchor;
484 484
         }
485 485
 
486 486
         // 检测域名
487 487
         $domain = $this->parseDomain($url, $domain);
488 488
 
489 489
         // URL组装
490
-        return $domain . rtrim($this->root, '/') . '/' . ltrim($url, '/');
490
+        return $domain.rtrim($this->root, '/').'/'.ltrim($url, '/');
491 491
     }
492 492
 
493 493
     public function __toString()
Please login to merge, or discard this patch.