@@ -8,7 +8,7 @@ discard block |
||
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; |
14 | 14 | |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | $this->ruleName = new RuleName(); |
178 | 178 | $this->setDefaultDomain(); |
179 | 179 | |
180 | - if (is_file($this->app->getRuntimePath() . 'route.php')) { |
|
180 | + if (is_file($this->app->getRuntimePath().'route.php')) { |
|
181 | 181 | // 读取路由映射文件 |
182 | - $this->import(include $this->app->getRuntimePath() . 'route.php'); |
|
182 | + $this->import(include $this->app->getRuntimePath().'route.php'); |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
@@ -420,13 +420,13 @@ discard block |
||
420 | 420 | if (is_null($domain)) { |
421 | 421 | $domain = $this->host; |
422 | 422 | } elseif (false === strpos($domain, '.')) { |
423 | - $domain .= '.' . $this->request->rootDomain(); |
|
423 | + $domain .= '.'.$this->request->rootDomain(); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | $subDomain = $this->request->subDomain(); |
427 | 427 | |
428 | 428 | if (strpos($subDomain, '.')) { |
429 | - $name = '*' . strstr($subDomain, '.'); |
|
429 | + $name = '*'.strstr($subDomain, '.'); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | if (isset($this->bind[$domain])) { |
@@ -773,9 +773,9 @@ discard block |
||
773 | 773 | |
774 | 774 | return $this->app->middleware->pipeline() |
775 | 775 | ->send($request) |
776 | - ->then(function ($request) use ($withRoute) { |
|
776 | + ->then(function($request) use ($withRoute) { |
|
777 | 777 | if ($withRoute) { |
778 | - $checkCallback = function () use ($withRoute) { |
|
778 | + $checkCallback = function() use ($withRoute) { |
|
779 | 779 | //加载路由 |
780 | 780 | $withRoute(); |
781 | 781 | return $this->check(); |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | $closure = $this->config['route_check_cache_key']; |
811 | 811 | $routeKey = $closure($request); |
812 | 812 | } else { |
813 | - $routeKey = md5($request->baseUrl(true) . ':' . $request->method()); |
|
813 | + $routeKey = md5($request->baseUrl(true).':'.$request->method()); |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | return $routeKey; |
@@ -860,10 +860,10 @@ discard block |
||
860 | 860 | $path = $pathinfo; |
861 | 861 | } elseif ($suffix) { |
862 | 862 | // 去除正常的URL后缀 |
863 | - $path = preg_replace('/\.(' . ltrim($suffix, '.') . ')$/i', '', $pathinfo); |
|
863 | + $path = preg_replace('/\.('.ltrim($suffix, '.').')$/i', '', $pathinfo); |
|
864 | 864 | } else { |
865 | 865 | // 允许任何后缀访问 |
866 | - $path = preg_replace('/\.' . $this->request->ext() . '$/i', '', $pathinfo); |
|
866 | + $path = preg_replace('/\.'.$this->request->ext().'$/i', '', $pathinfo); |
|
867 | 867 | } |
868 | 868 | |
869 | 869 | return $path; |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | $appName = $map[$name]; |
892 | 892 | } |
893 | 893 | } elseif ($name && (false !== array_search($name, $map) || in_array($name, $deny))) { |
894 | - throw new HttpException(404, 'app not exists:' . $name); |
|
894 | + throw new HttpException(404, 'app not exists:'.$name); |
|
895 | 895 | } elseif ($name && isset($map['*'])) { |
896 | 896 | $appName = $map['*']; |
897 | 897 | } else { |
@@ -899,7 +899,7 @@ discard block |
||
899 | 899 | } |
900 | 900 | |
901 | 901 | if ($name) { |
902 | - $this->request->setRoot('/' . $name); |
|
902 | + $this->request->setRoot('/'.$name); |
|
903 | 903 | $url = strpos($path, '/') ? ltrim(strstr($path, '/'), '/') : ''; |
904 | 904 | $this->request->setPathinfo($url); |
905 | 905 | } |
@@ -936,9 +936,9 @@ discard block |
||
936 | 936 | $item = $this->domains[$this->host]; |
937 | 937 | } elseif (isset($this->domains[$subDomain])) { |
938 | 938 | $item = $this->domains[$subDomain]; |
939 | - } elseif (isset($this->domains['*.' . $domain2]) && !empty($domain3)) { |
|
939 | + } elseif (isset($this->domains['*.'.$domain2]) && !empty($domain3)) { |
|
940 | 940 | // 泛三级域名 |
941 | - $item = $this->domains['*.' . $domain2]; |
|
941 | + $item = $this->domains['*.'.$domain2]; |
|
942 | 942 | $panDomain = $domain3; |
943 | 943 | } elseif (isset($this->domains['*']) && !empty($domain2)) { |
944 | 944 | // 泛二级域名 |
@@ -8,7 +8,7 @@ discard block |
||
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; |
14 | 14 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | public function __construct(App $app) |
58 | 58 | { |
59 | 59 | $this->app = $app; |
60 | - $this->multi = is_dir($this->app->getBasePath() . 'controller') ? false : true; |
|
60 | + $this->multi = is_dir($this->app->getBasePath().'controller') ? false : true; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | |
194 | 194 | protected function dispatchToRoute($request) |
195 | 195 | { |
196 | - $withRoute = $this->app->config->get('app.with_route', true) ? function () { |
|
196 | + $withRoute = $this->app->config->get('app.with_route', true) ? function() { |
|
197 | 197 | $this->loadRoutes(); |
198 | 198 | } : null; |
199 | 199 | |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | */ |
206 | 206 | protected function loadMiddleware(): void |
207 | 207 | { |
208 | - if (is_file($this->app->getBasePath() . 'middleware.php')) { |
|
209 | - $this->app->middleware->import(include $this->app->getBasePath() . 'middleware.php'); |
|
208 | + if (is_file($this->app->getBasePath().'middleware.php')) { |
|
209 | + $this->app->middleware->import(include $this->app->getBasePath().'middleware.php'); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | |
@@ -217,17 +217,17 @@ discard block |
||
217 | 217 | */ |
218 | 218 | protected function loadRoutes(): void |
219 | 219 | { |
220 | - $routePath = $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR; |
|
220 | + $routePath = $this->app->getRootPath().'route'.DIRECTORY_SEPARATOR; |
|
221 | 221 | |
222 | 222 | if ($this->name) { |
223 | 223 | // 加载多应用模式的具体应用路由定义 |
224 | - $routeFile = $routePath . $this->name . '.php'; |
|
224 | + $routeFile = $routePath.$this->name.'.php'; |
|
225 | 225 | if (is_file($routeFile)) { |
226 | 226 | include $routeFile; |
227 | 227 | } |
228 | 228 | } else { |
229 | 229 | // 单应用或者未识别的多应用路由定义 |
230 | - $files = glob($routePath . '*.php'); |
|
230 | + $files = glob($routePath.'*.php'); |
|
231 | 231 | foreach ($files as $file) { |
232 | 232 | if ($this->isMulti()) { |
233 | 233 | $this->app->route->setAppName(pathinfo($file, PATHINFO_FILENAME)); |
@@ -327,11 +327,11 @@ discard block |
||
327 | 327 | { |
328 | 328 | $this->name = $appName; |
329 | 329 | $this->app->request->setApp($appName); |
330 | - $this->app->setAppPath($this->path ?: $this->app->getBasePath() . $appName . DIRECTORY_SEPARATOR); |
|
331 | - $this->app->setRuntimePath($this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . $appName . DIRECTORY_SEPARATOR); |
|
330 | + $this->app->setAppPath($this->path ?: $this->app->getBasePath().$appName.DIRECTORY_SEPARATOR); |
|
331 | + $this->app->setRuntimePath($this->app->getRootPath().'runtime'.DIRECTORY_SEPARATOR.$appName.DIRECTORY_SEPARATOR); |
|
332 | 332 | |
333 | 333 | // 设置应用命名空间 |
334 | - $this->app->setNamespace($this->app->config->get('app.app_namespace') ?: 'app\\' . $appName); |
|
334 | + $this->app->setNamespace($this->app->config->get('app.app_namespace') ?: 'app\\'.$appName); |
|
335 | 335 | |
336 | 336 | //加载应用 |
337 | 337 | $this->loadApp($appName); |
@@ -348,34 +348,34 @@ discard block |
||
348 | 348 | if (is_dir($this->app->getAppPath())) { |
349 | 349 | $appPath = $this->app->getAppPath(); |
350 | 350 | |
351 | - if (is_file($appPath . 'common.php')) { |
|
352 | - include_once $appPath . 'common.php'; |
|
351 | + if (is_file($appPath.'common.php')) { |
|
352 | + include_once $appPath.'common.php'; |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | $configPath = $this->app->getConfigPath(); |
356 | 356 | |
357 | 357 | $files = []; |
358 | 358 | |
359 | - if (is_dir($appPath . 'config')) { |
|
360 | - $files = array_merge($files, glob($appPath . 'config' . DIRECTORY_SEPARATOR . '*' . $this->app->getConfigExt())); |
|
361 | - } elseif (is_dir($configPath . $appName)) { |
|
362 | - $files = array_merge($files, glob($configPath . $appName . DIRECTORY_SEPARATOR . '*' . $this->app->getConfigExt())); |
|
359 | + if (is_dir($appPath.'config')) { |
|
360 | + $files = array_merge($files, glob($appPath.'config'.DIRECTORY_SEPARATOR.'*'.$this->app->getConfigExt())); |
|
361 | + } elseif (is_dir($configPath.$appName)) { |
|
362 | + $files = array_merge($files, glob($configPath.$appName.DIRECTORY_SEPARATOR.'*'.$this->app->getConfigExt())); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | foreach ($files as $file) { |
366 | 366 | $this->app->config->load($file, pathinfo($file, PATHINFO_FILENAME)); |
367 | 367 | } |
368 | 368 | |
369 | - if (is_file($appPath . 'event.php')) { |
|
370 | - $this->app->loadEvent(include $appPath . 'event.php'); |
|
369 | + if (is_file($appPath.'event.php')) { |
|
370 | + $this->app->loadEvent(include $appPath.'event.php'); |
|
371 | 371 | } |
372 | 372 | |
373 | - if (is_file($appPath . 'middleware.php')) { |
|
374 | - $this->app->middleware->import(include $appPath . 'middleware.php'); |
|
373 | + if (is_file($appPath.'middleware.php')) { |
|
374 | + $this->app->middleware->import(include $appPath.'middleware.php'); |
|
375 | 375 | } |
376 | 376 | |
377 | - if (is_file($appPath . 'provider.php')) { |
|
378 | - $this->app->bind(include $appPath . 'provider.php'); |
|
377 | + if (is_file($appPath.'provider.php')) { |
|
378 | + $this->app->bind(include $appPath.'provider.php'); |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 |
@@ -8,7 +8,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 | /** |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | $app = empty($path) ? $app : array_pop($path); |
256 | 256 | } |
257 | 257 | |
258 | - $url = $controller . '/' . $action; |
|
258 | + $url = $controller.'/'.$action; |
|
259 | 259 | |
260 | 260 | if ($app && $this->app->config->get('app.auto_multi_app')) { |
261 | 261 | $bind = $this->app->config->get('app.domain_bind', []); |
@@ -265,9 +265,9 @@ discard block |
||
265 | 265 | $map = $this->app->config->get('app.app_map', []); |
266 | 266 | |
267 | 267 | if ($key = array_search($app, $map)) { |
268 | - $url = $key . '/' . $url; |
|
268 | + $url = $key.'/'.$url; |
|
269 | 269 | } else { |
270 | - $url = $app . '/' . $url; |
|
270 | + $url = $app.'/'.$url; |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 | } |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | { |
318 | 318 | $request = $this->app->request; |
319 | 319 | if (false === strpos($allowDomain, '.')) { |
320 | - $allowDomain .= '.' . $request->rootDomain(); |
|
320 | + $allowDomain .= '.'.$request->rootDomain(); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | foreach ($rule as $item) { |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | } |
336 | 336 | |
337 | 337 | if (!in_array($request->port(), [80, 443])) { |
338 | - $domain .= ':' . $request->port(); |
|
338 | + $domain .= ':'.$request->port(); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | if (empty($pattern)) { |
@@ -346,12 +346,12 @@ discard block |
||
346 | 346 | |
347 | 347 | foreach ($pattern as $key => $val) { |
348 | 348 | if (isset($vars[$key])) { |
349 | - $url = str_replace(['[:' . $key . ']', '<' . $key . '?>', ':' . $key, '<' . $key . '>'], $type ? $vars[$key] : urlencode((string) $vars[$key]), $url); |
|
349 | + $url = str_replace(['[:'.$key.']', '<'.$key.'?>', ':'.$key, '<'.$key.'>'], $type ? $vars[$key] : urlencode((string) $vars[$key]), $url); |
|
350 | 350 | unset($vars[$key]); |
351 | 351 | $url = str_replace(['/?', '-?'], ['/', '-'], $url); |
352 | 352 | $result = [rtrim($url, '?/-'), $domain, $suffix]; |
353 | 353 | } elseif (2 == $val) { |
354 | - $url = str_replace(['/[:' . $key . ']', '[:' . $key . ']', '<' . $key . '?>'], '', $url); |
|
354 | + $url = str_replace(['/[:'.$key.']', '[:'.$key.']', '<'.$key.'?>'], '', $url); |
|
355 | 355 | $url = str_replace(['/?', '-?'], ['/', '-'], $url); |
356 | 356 | $result = [rtrim($url, '?/-'), $domain, $suffix]; |
357 | 357 | } else { |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | if (0 === strpos($url, '[') && $pos = strpos($url, ']')) { |
380 | 380 | // [name] 表示使用路由命名标识生成URL |
381 | 381 | $name = substr($url, 1, $pos - 1); |
382 | - $url = 'name' . substr($url, $pos + 1); |
|
382 | + $url = 'name'.substr($url, $pos + 1); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | if (false === strpos($url, '://') && 0 !== strpos($url, '/')) { |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | } |
407 | 407 | |
408 | 408 | if ($url) { |
409 | - $checkName = isset($name) ? $name : $url . (isset($info['query']) ? '?' . $info['query'] : ''); |
|
409 | + $checkName = isset($name) ? $name : $url.(isset($info['query']) ? '?'.$info['query'] : ''); |
|
410 | 410 | $checkDomain = $domain && is_string($domain) ? $domain : null; |
411 | 411 | |
412 | 412 | $rule = $this->route->getName($checkName, $checkDomain); |
@@ -433,10 +433,10 @@ discard block |
||
433 | 433 | } |
434 | 434 | |
435 | 435 | if ($request->app() && $this->app->config->get('app.auto_multi_app') && !$this->app->http->isBindDomain()) { |
436 | - $url = $request->app() . '/' . $url; |
|
436 | + $url = $request->app().'/'.$url; |
|
437 | 437 | } |
438 | 438 | } elseif (!empty($rule) && isset($name)) { |
439 | - throw new \InvalidArgumentException('route name not exists:' . $name); |
|
439 | + throw new \InvalidArgumentException('route name not exists:'.$name); |
|
440 | 440 | } else { |
441 | 441 | // 检测URL绑定 |
442 | 442 | $bind = $this->route->getDomainBind($domain && is_string($domain) ? $domain : null); |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | $file = str_replace('\\', '/', dirname($file)); |
475 | 475 | } |
476 | 476 | |
477 | - $url = rtrim($file, '/') . '/' . $url; |
|
477 | + $url = rtrim($file, '/').'/'.$url; |
|
478 | 478 | |
479 | 479 | // URL后缀 |
480 | 480 | if ('/' == substr($url, -1) || '' == $url) { |
@@ -484,32 +484,32 @@ discard block |
||
484 | 484 | } |
485 | 485 | |
486 | 486 | // 锚点 |
487 | - $anchor = !empty($anchor) ? '#' . $anchor : ''; |
|
487 | + $anchor = !empty($anchor) ? '#'.$anchor : ''; |
|
488 | 488 | |
489 | 489 | // 参数组装 |
490 | 490 | if (!empty($vars)) { |
491 | 491 | // 添加参数 |
492 | 492 | if ($this->route->config('url_common_param')) { |
493 | 493 | $vars = http_build_query($vars); |
494 | - $url .= $suffix . '?' . $vars . $anchor; |
|
494 | + $url .= $suffix.'?'.$vars.$anchor; |
|
495 | 495 | } else { |
496 | 496 | foreach ($vars as $var => $val) { |
497 | 497 | if ('' !== $val) { |
498 | - $url .= $depr . $var . $depr . urlencode((string) $val); |
|
498 | + $url .= $depr.$var.$depr.urlencode((string) $val); |
|
499 | 499 | } |
500 | 500 | } |
501 | 501 | |
502 | - $url .= $suffix . $anchor; |
|
502 | + $url .= $suffix.$anchor; |
|
503 | 503 | } |
504 | 504 | } else { |
505 | - $url .= $suffix . $anchor; |
|
505 | + $url .= $suffix.$anchor; |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | // 检测域名 |
509 | 509 | $domain = $this->parseDomain($url, $domain); |
510 | 510 | |
511 | 511 | // URL组装 |
512 | - return $domain . rtrim($this->root, '/') . '/' . ltrim($url, '/'); |
|
512 | + return $domain.rtrim($this->root, '/').'/'.ltrim($url, '/'); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | public function __toString() |