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