Passed
Pull Request — 5.1 (#2042)
by
unknown
09:47
created
library/think/Url.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
         $this->app    = $app;
43 43
         $this->config = $config;
44 44
 
45
-        if (is_file($app->getRuntimePath() . 'route.php')) {
45
+        if (is_file($app->getRuntimePath().'route.php')) {
46 46
             // 读取路由映射文件
47
-            $app['route']->setName(include $app->getRuntimePath() . 'route.php');
47
+            $app['route']->setName(include $app->getRuntimePath().'route.php');
48 48
         }
49 49
     }
50 50
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         if (0 === strpos($url, '[') && $pos = strpos($url, ']')) {
80 80
             // [name] 表示使用路由命名标识生成URL
81 81
             $name = substr($url, 1, $pos - 1);
82
-            $url  = 'name' . substr($url, $pos + 1);
82
+            $url  = 'name'.substr($url, $pos + 1);
83 83
         }
84 84
 
85 85
         if (false === strpos($url, '://') && 0 !== strpos($url, '/')) {
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
         }
113 113
 
114 114
         if ($url) {
115
-            $checkName   = isset($name) ? $name : $url . (isset($info['query']) ? '?' . $info['query'] : '');
115
+            $checkName   = isset($name) ? $name : $url.(isset($info['query']) ? '?'.$info['query'] : '');
116 116
             $checkDomain = $domain && is_string($domain) ? $domain : null;
117 117
 
118 118
             $rule = $this->app['route']->getName($checkName, $checkDomain);
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
                 $suffix = $match[2];
139 139
             }
140 140
         } elseif (!empty($rule) && isset($name)) {
141
-            throw new \InvalidArgumentException('route name not exists:' . $name);
141
+            throw new \InvalidArgumentException('route name not exists:'.$name);
142 142
         } else {
143 143
             // 检查别名路由
144 144
             $alias      = $this->app['route']->getAlias();
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
                     $val = $item->getRoute();
151 151
 
152 152
                     if (0 === strpos($url, $val)) {
153
-                        $url        = $key . substr($url, strlen($val));
153
+                        $url        = $key.substr($url, strlen($val));
154 154
                         $matchAlias = true;
155 155
                         break;
156 156
                     }
@@ -200,38 +200,38 @@  discard block
 block discarded – undo
200 200
         }
201 201
 
202 202
         // 锚点
203
-        $anchor = !empty($anchor) ? '#' . $anchor : '';
203
+        $anchor = !empty($anchor) ? '#'.$anchor : '';
204 204
 
205 205
         // 参数组装
206 206
         if (!empty($vars)) {
207 207
             // 添加参数
208 208
             if ($this->config['url_common_param']) {
209 209
                 $vars = http_build_query($vars);
210
-                $url .= $suffix . '?' . $vars . $anchor;
210
+                $url .= $suffix.'?'.$vars.$anchor;
211 211
             } else {
212 212
                 $paramType = $this->config['url_param_type'];
213 213
 
214 214
                 foreach ($vars as $var => $val) {
215 215
                     if ('' !== trim($val)) {
216 216
                         if ($paramType) {
217
-                            $url .= $depr . urlencode($val);
217
+                            $url .= $depr.urlencode($val);
218 218
                         } else {
219
-                            $url .= $depr . $var . $depr . urlencode($val);
219
+                            $url .= $depr.$var.$depr.urlencode($val);
220 220
                         }
221 221
                     }
222 222
                 }
223 223
 
224
-                $url .= $suffix . $anchor;
224
+                $url .= $suffix.$anchor;
225 225
             }
226 226
         } else {
227
-            $url .= $suffix . $anchor;
227
+            $url .= $suffix.$anchor;
228 228
         }
229 229
 
230 230
         // 检测域名
231 231
         $domain = $this->parseDomain($url, $domain);
232 232
 
233 233
         // URL组装
234
-        $url = $domain . rtrim($this->root ?: $this->app['request']->root(), '/') . '/' . ltrim($url, '/');
234
+        $url = $domain.rtrim($this->root ?: $this->app['request']->root(), '/').'/'.ltrim($url, '/');
235 235
 
236 236
         $this->bindCheck = false;
237 237
 
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
         } else {
256 256
             // 解析到 模块/控制器/操作
257 257
             $module     = $request->module();
258
-            $module     = $module ? $module . '/' : '';
258
+            $module     = $module ? $module.'/' : '';
259 259
             $controller = $request->controller();
260 260
 
261 261
             if ('' == $url) {
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
                 $path       = explode('/', $url);
265 265
                 $action     = array_pop($path);
266 266
                 $controller = empty($path) ? $controller : array_pop($path);
267
-                $module     = empty($path) ? $module : array_pop($path) . '/';
267
+                $module     = empty($path) ? $module : array_pop($path).'/';
268 268
             }
269 269
 
270 270
             if ($this->config['url_convert']) {
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
                 $controller = Loader::parseName($controller);
273 273
             }
274 274
 
275
-            $url = $module . $controller . '/' . $action;
275
+            $url = $module.$controller.'/'.$action;
276 276
         }
277 277
 
278 278
         return $url;
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
                 }
320 320
             }
321 321
         } elseif (0 !== strpos($domain, $rootDomain) && false === strpos($domain, '.')) {
322
-            $domain .= '.' . $rootDomain;
322
+            $domain .= '.'.$rootDomain;
323 323
         }
324 324
 
325 325
         if (false !== strpos($domain, '://')) {
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 
330 330
         }
331 331
 
332
-        return $scheme . $domain;
332
+        return $scheme.$domain;
333 333
     }
334 334
 
335 335
     // 解析URL后缀
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
             }
344 344
         }
345 345
 
346
-        return (empty($suffix) || 0 === strpos($suffix, '.')) ? $suffix : '.' . $suffix;
346
+        return (empty($suffix) || 0 === strpos($suffix, '.')) ? $suffix : '.'.$suffix;
347 347
     }
348 348
 
349 349
     // 匹配路由地址
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
             }
359 359
 
360 360
             if ($port && !in_array($port, [80, 443])) {
361
-                $domain .= ':' . $port;
361
+                $domain .= ':'.$port;
362 362
             }
363 363
 
364 364
             if (empty($pattern)) {
@@ -369,12 +369,12 @@  discard block
 block discarded – undo
369 369
 
370 370
             foreach ($pattern as $key => $val) {
371 371
                 if (isset($vars[$key])) {
372
-                    $url = str_replace(['[:' . $key . ']', '<' . $key . '?>', ':' . $key, '<' . $key . '>'], $type ? $vars[$key] : urlencode($vars[$key]), $url);
372
+                    $url = str_replace(['[:'.$key.']', '<'.$key.'?>', ':'.$key, '<'.$key.'>'], $type ? $vars[$key] : urlencode($vars[$key]), $url);
373 373
                     unset($vars[$key]);
374 374
                     $url    = str_replace(['/?', '-?'], ['/', '-'], $url);
375 375
                     $result = [rtrim($url, '?/-'), $domain, $suffix];
376 376
                 } elseif (2 == $val) {
377
-                    $url    = str_replace(['/[:' . $key . ']', '[:' . $key . ']', '<' . $key . '?>'], '', $url);
377
+                    $url    = str_replace(['/[:'.$key.']', '[:'.$key.']', '<'.$key.'?>'], '', $url);
378 378
                     $url    = str_replace(['/?', '-?'], ['/', '-'], $url);
379 379
                     $result = [rtrim($url, '?/-'), $domain, $suffix];
380 380
                 } else {
Please login to merge, or discard this patch.