@@ -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])) { |
@@ -760,7 +760,7 @@ discard block |
||
| 760 | 760 | $this->init(); |
| 761 | 761 | |
| 762 | 762 | if ($withRoute) { |
| 763 | - $checkCallback = function () use ($withRoute) { |
|
| 763 | + $checkCallback = function() use ($withRoute) { |
|
| 764 | 764 | //加载路由 |
| 765 | 765 | $withRoute(); |
| 766 | 766 | return $this->check(); |
@@ -781,7 +781,7 @@ discard block |
||
| 781 | 781 | |
| 782 | 782 | return $this->app->middleware->pipeline('route') |
| 783 | 783 | ->send($request) |
| 784 | - ->then(function () use ($dispatch) { |
|
| 784 | + ->then(function() use ($dispatch) { |
|
| 785 | 785 | return $dispatch->run(); |
| 786 | 786 | }); |
| 787 | 787 | } |
@@ -798,7 +798,7 @@ discard block |
||
| 798 | 798 | $closure = $this->config['route_check_cache_key']; |
| 799 | 799 | $routeKey = $closure($request); |
| 800 | 800 | } else { |
| 801 | - $routeKey = md5($request->baseUrl(true) . ':' . $request->method()); |
|
| 801 | + $routeKey = md5($request->baseUrl(true).':'.$request->method()); |
|
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | return $routeKey; |
@@ -848,10 +848,10 @@ discard block |
||
| 848 | 848 | $path = $pathinfo; |
| 849 | 849 | } elseif ($suffix) { |
| 850 | 850 | // 去除正常的URL后缀 |
| 851 | - $path = preg_replace('/\.(' . ltrim($suffix, '.') . ')$/i', '', $pathinfo); |
|
| 851 | + $path = preg_replace('/\.('.ltrim($suffix, '.').')$/i', '', $pathinfo); |
|
| 852 | 852 | } else { |
| 853 | 853 | // 允许任何后缀访问 |
| 854 | - $path = preg_replace('/\.' . $this->request->ext() . '$/i', '', $pathinfo); |
|
| 854 | + $path = preg_replace('/\.'.$this->request->ext().'$/i', '', $pathinfo); |
|
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | return $path; |
@@ -880,7 +880,7 @@ discard block |
||
| 880 | 880 | $appName = $map[$name]; |
| 881 | 881 | } |
| 882 | 882 | } elseif ($name && (false !== array_search($name, $map) || in_array($name, $deny))) { |
| 883 | - throw new HttpException(404, 'app not exists:' . $name); |
|
| 883 | + throw new HttpException(404, 'app not exists:'.$name); |
|
| 884 | 884 | } elseif ($name && isset($map['*'])) { |
| 885 | 885 | $appName = $map['*']; |
| 886 | 886 | } else { |
@@ -923,9 +923,9 @@ discard block |
||
| 923 | 923 | $item = $this->domains[$this->host]; |
| 924 | 924 | } elseif (isset($this->domains[$subDomain])) { |
| 925 | 925 | $item = $this->domains[$subDomain]; |
| 926 | - } elseif (isset($this->domains['*.' . $domain2]) && !empty($domain3)) { |
|
| 926 | + } elseif (isset($this->domains['*.'.$domain2]) && !empty($domain3)) { |
|
| 927 | 927 | // 泛三级域名 |
| 928 | - $item = $this->domains['*.' . $domain2]; |
|
| 928 | + $item = $this->domains['*.'.$domain2]; |
|
| 929 | 929 | $panDomain = $domain3; |
| 930 | 930 | } elseif (isset($this->domains['*']) && !empty($domain2)) { |
| 931 | 931 | // 泛二级域名 |
@@ -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 | /** |
@@ -195,8 +195,8 @@ discard block |
||
| 195 | 195 | |
| 196 | 196 | protected function dispatchToRoute() |
| 197 | 197 | { |
| 198 | - return function ($request) { |
|
| 199 | - $withRoute = $this->app->config->get('app.with_route', true) ? function () { |
|
| 198 | + return function($request) { |
|
| 199 | + $withRoute = $this->app->config->get('app.with_route', true) ? function() { |
|
| 200 | 200 | $this->loadRoutes(); |
| 201 | 201 | } : null; |
| 202 | 202 | |
@@ -209,8 +209,8 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | protected function loadMiddleware(): void |
| 211 | 211 | { |
| 212 | - if (is_file($this->app->getBasePath() . 'middleware.php')) { |
|
| 213 | - $this->app->middleware->import(include $this->app->getBasePath() . 'middleware.php'); |
|
| 212 | + if (is_file($this->app->getBasePath().'middleware.php')) { |
|
| 213 | + $this->app->middleware->import(include $this->app->getBasePath().'middleware.php'); |
|
| 214 | 214 | } |
| 215 | 215 | } |
| 216 | 216 | |
@@ -221,17 +221,17 @@ discard block |
||
| 221 | 221 | */ |
| 222 | 222 | protected function loadRoutes(): void |
| 223 | 223 | { |
| 224 | - $routePath = $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR; |
|
| 224 | + $routePath = $this->app->getRootPath().'route'.DIRECTORY_SEPARATOR; |
|
| 225 | 225 | |
| 226 | 226 | if ($this->name) { |
| 227 | 227 | // 加载多应用模式的具体应用路由定义 |
| 228 | - $routeFile = $routePath . $this->name . '.php'; |
|
| 228 | + $routeFile = $routePath.$this->name.'.php'; |
|
| 229 | 229 | if (is_file($routeFile)) { |
| 230 | 230 | include $routeFile; |
| 231 | 231 | } |
| 232 | 232 | } else { |
| 233 | 233 | // 单应用或者未识别的多应用路由定义 |
| 234 | - $files = glob($routePath . '*.php'); |
|
| 234 | + $files = glob($routePath.'*.php'); |
|
| 235 | 235 | foreach ($files as $file) { |
| 236 | 236 | if ($this->isMulti()) { |
| 237 | 237 | $this->app->route->setAppName(pathinfo($file, PATHINFO_FILENAME)); |
@@ -332,11 +332,11 @@ discard block |
||
| 332 | 332 | { |
| 333 | 333 | $this->name = $appName; |
| 334 | 334 | $this->app->request->setApp($appName); |
| 335 | - $this->app->setAppPath($this->path ?: $this->app->getBasePath() . $appName . DIRECTORY_SEPARATOR); |
|
| 336 | - $this->app->setRuntimePath($this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . $appName . DIRECTORY_SEPARATOR); |
|
| 335 | + $this->app->setAppPath($this->path ?: $this->app->getBasePath().$appName.DIRECTORY_SEPARATOR); |
|
| 336 | + $this->app->setRuntimePath($this->app->getRootPath().'runtime'.DIRECTORY_SEPARATOR.$appName.DIRECTORY_SEPARATOR); |
|
| 337 | 337 | |
| 338 | 338 | // 设置应用命名空间 |
| 339 | - $this->app->setNamespace($this->app->config->get('app.app_namespace') ?: 'app\\' . $appName); |
|
| 339 | + $this->app->setNamespace($this->app->config->get('app.app_namespace') ?: 'app\\'.$appName); |
|
| 340 | 340 | |
| 341 | 341 | //加载应用 |
| 342 | 342 | $this->loadApp($appName); |
@@ -353,34 +353,34 @@ discard block |
||
| 353 | 353 | if (is_dir($this->app->getAppPath())) { |
| 354 | 354 | $appPath = $this->app->getAppPath(); |
| 355 | 355 | |
| 356 | - if (is_file($appPath . 'common.php')) { |
|
| 357 | - include_once $appPath . 'common.php'; |
|
| 356 | + if (is_file($appPath.'common.php')) { |
|
| 357 | + include_once $appPath.'common.php'; |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | $configPath = $this->app->getConfigPath(); |
| 361 | 361 | |
| 362 | 362 | $files = []; |
| 363 | 363 | |
| 364 | - if (is_dir($appPath . 'config')) { |
|
| 365 | - $files = array_merge($files, glob($appPath . 'config' . DIRECTORY_SEPARATOR . '*' . $this->app->getConfigExt())); |
|
| 366 | - } elseif (is_dir($configPath . $appName)) { |
|
| 367 | - $files = array_merge($files, glob($configPath . $appName . DIRECTORY_SEPARATOR . '*' . $this->app->getConfigExt())); |
|
| 364 | + if (is_dir($appPath.'config')) { |
|
| 365 | + $files = array_merge($files, glob($appPath.'config'.DIRECTORY_SEPARATOR.'*'.$this->app->getConfigExt())); |
|
| 366 | + } elseif (is_dir($configPath.$appName)) { |
|
| 367 | + $files = array_merge($files, glob($configPath.$appName.DIRECTORY_SEPARATOR.'*'.$this->app->getConfigExt())); |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | foreach ($files as $file) { |
| 371 | 371 | $this->app->config->load($file, pathinfo($file, PATHINFO_FILENAME)); |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - if (is_file($appPath . 'event.php')) { |
|
| 375 | - $this->app->loadEvent(include $appPath . 'event.php'); |
|
| 374 | + if (is_file($appPath.'event.php')) { |
|
| 375 | + $this->app->loadEvent(include $appPath.'event.php'); |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - if (is_file($appPath . 'middleware.php')) { |
|
| 379 | - $this->app->middleware->import(include $appPath . 'middleware.php'); |
|
| 378 | + if (is_file($appPath.'middleware.php')) { |
|
| 379 | + $this->app->middleware->import(include $appPath.'middleware.php'); |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | - if (is_file($appPath . 'provider.php')) { |
|
| 383 | - $this->app->bind(include $appPath . 'provider.php'); |
|
| 382 | + if (is_file($appPath.'provider.php')) { |
|
| 383 | + $this->app->bind(include $appPath.'provider.php'); |
|
| 384 | 384 | } |
| 385 | 385 | } |
| 386 | 386 | |