Completed
Push — 6.0 ( 8a4f1d...78e73d )
by liu
06:08
created
src/think/route/Url.php 1 patch
Spacing   +19 added lines, -19 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
     /**
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
             $action     = array_pop($path);
249 249
             $controller = empty($path) ? $controller : array_pop($path);
250 250
 
251
-            $url = $controller . '/' . $action;
251
+            $url = $controller.'/'.$action;
252 252
         }
253 253
 
254 254
         return $url;
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
     {
296 296
         $request = $this->app->request;
297 297
         if (is_string($allowDomain) && false === strpos($allowDomain, '.')) {
298
-            $allowDomain .= '.' . $request->rootDomain();
298
+            $allowDomain .= '.'.$request->rootDomain();
299 299
         }
300 300
         $port = $request->port();
301 301
 
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
             }
315 315
 
316 316
             if ($port && !in_array($port, [80, 443])) {
317
-                $domain .= ':' . $port;
317
+                $domain .= ':'.$port;
318 318
             }
319 319
 
320 320
             if (empty($pattern)) {
@@ -325,12 +325,12 @@  discard block
 block discarded – undo
325 325
 
326 326
             foreach ($pattern as $key => $val) {
327 327
                 if (isset($vars[$key])) {
328
-                    $url = str_replace(['[:' . $key . ']', '<' . $key . '?>', ':' . $key, '<' . $key . '>'], $type ? $vars[$key] : urlencode((string) $vars[$key]), $url);
328
+                    $url = str_replace(['[:'.$key.']', '<'.$key.'?>', ':'.$key, '<'.$key.'>'], $type ? $vars[$key] : urlencode((string) $vars[$key]), $url);
329 329
                     unset($vars[$key]);
330 330
                     $url    = str_replace(['/?', '-?'], ['/', '-'], $url);
331 331
                     $result = [rtrim($url, '?/-'), $domain, $suffix];
332 332
                 } elseif (2 == $val) {
333
-                    $url    = str_replace(['/[:' . $key . ']', '[:' . $key . ']', '<' . $key . '?>'], '', $url);
333
+                    $url    = str_replace(['/[:'.$key.']', '[:'.$key.']', '<'.$key.'?>'], '', $url);
334 334
                     $url    = str_replace(['/?', '-?'], ['/', '-'], $url);
335 335
                     $result = [rtrim($url, '?/-'), $domain, $suffix];
336 336
                 } else {
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
         if (0 === strpos($url, '[') && $pos = strpos($url, ']')) {
359 359
             // [name] 表示使用路由命名标识生成URL
360 360
             $name = substr($url, 1, $pos - 1);
361
-            $url  = 'name' . substr($url, $pos + 1);
361
+            $url  = 'name'.substr($url, $pos + 1);
362 362
         }
363 363
 
364 364
         if (false === strpos($url, '://') && 0 !== strpos($url, '/')) {
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
         }
386 386
 
387 387
         if ($url) {
388
-            $checkName   = isset($name) ? $name : $url . (isset($info['query']) ? '?' . $info['query'] : '');
388
+            $checkName   = isset($name) ? $name : $url.(isset($info['query']) ? '?'.$info['query'] : '');
389 389
             $checkDomain = $domain && is_string($domain) ? $domain : null;
390 390
 
391 391
             $rule = $this->route->getName($checkName, $checkDomain);
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
                 $suffix = $match[2];
412 412
             }
413 413
         } elseif (!empty($rule) && isset($name)) {
414
-            throw new \InvalidArgumentException('route name not exists:' . $name);
414
+            throw new \InvalidArgumentException('route name not exists:'.$name);
415 415
         } else {
416 416
             // 检测URL绑定
417 417
             $bind = $this->route->getDomainBind($domain && is_string($domain) ? $domain : null);
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
             $file = str_replace('\\', '/', dirname($file));
450 450
         }
451 451
 
452
-        $url = rtrim($file, '/') . '/' . $url;
452
+        $url = rtrim($file, '/').'/'.$url;
453 453
 
454 454
         // URL后缀
455 455
         if ('/' == substr($url, -1) || '' == $url) {
@@ -459,32 +459,32 @@  discard block
 block discarded – undo
459 459
         }
460 460
 
461 461
         // 锚点
462
-        $anchor = !empty($anchor) ? '#' . $anchor : '';
462
+        $anchor = !empty($anchor) ? '#'.$anchor : '';
463 463
 
464 464
         // 参数组装
465 465
         if (!empty($vars)) {
466 466
             // 添加参数
467 467
             if ($this->route->config('url_common_param')) {
468 468
                 $vars = http_build_query($vars);
469
-                $url .= $suffix . '?' . $vars . $anchor;
469
+                $url .= $suffix.'?'.$vars.$anchor;
470 470
             } else {
471 471
                 foreach ($vars as $var => $val) {
472 472
                     if ('' !== $val) {
473
-                        $url .= $depr . $var . $depr . urlencode((string) $val);
473
+                        $url .= $depr.$var.$depr.urlencode((string) $val);
474 474
                     }
475 475
                 }
476 476
 
477
-                $url .= $suffix . $anchor;
477
+                $url .= $suffix.$anchor;
478 478
             }
479 479
         } else {
480
-            $url .= $suffix . $anchor;
480
+            $url .= $suffix.$anchor;
481 481
         }
482 482
 
483 483
         // 检测域名
484 484
         $domain = $this->parseDomain($url, $domain);
485 485
 
486 486
         // URL组装
487
-        return $domain . rtrim($this->root, '/') . '/' . ltrim($url, '/');
487
+        return $domain.rtrim($this->root, '/').'/'.ltrim($url, '/');
488 488
     }
489 489
 
490 490
     public function __toString()
Please login to merge, or discard this patch.