@@ -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 | |
@@ -170,9 +170,9 @@ discard block |
||
| 170 | 170 | $this->ruleName = new RuleName(); |
| 171 | 171 | $this->setDefaultDomain(); |
| 172 | 172 | |
| 173 | - if (is_file($this->app->getRuntimePath() . 'route.php')) { |
|
| 173 | + if (is_file($this->app->getRuntimePath().'route.php')) { |
|
| 174 | 174 | // 读取路由映射文件 |
| 175 | - $this->import(include $this->app->getRuntimePath() . 'route.php'); |
|
| 175 | + $this->import(include $this->app->getRuntimePath().'route.php'); |
|
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | |
@@ -402,13 +402,13 @@ discard block |
||
| 402 | 402 | if (is_null($domain)) { |
| 403 | 403 | $domain = $this->host; |
| 404 | 404 | } elseif (false === strpos($domain, '.')) { |
| 405 | - $domain .= '.' . $this->request->rootDomain(); |
|
| 405 | + $domain .= '.'.$this->request->rootDomain(); |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | $subDomain = $this->request->subDomain(); |
| 409 | 409 | |
| 410 | 410 | if (strpos($subDomain, '.')) { |
| 411 | - $name = '*' . strstr($subDomain, '.'); |
|
| 411 | + $name = '*'.strstr($subDomain, '.'); |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | if (isset($this->bind[$domain])) { |
@@ -740,7 +740,7 @@ discard block |
||
| 740 | 740 | $this->init(); |
| 741 | 741 | |
| 742 | 742 | if ($withRoute) { |
| 743 | - $checkCallback = function () use ($withRoute) { |
|
| 743 | + $checkCallback = function() use ($withRoute) { |
|
| 744 | 744 | //加载路由 |
| 745 | 745 | $withRoute(); |
| 746 | 746 | return $this->check(); |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | |
| 762 | 762 | return $this->app->middleware->pipeline('route') |
| 763 | 763 | ->send($request) |
| 764 | - ->then(function () use ($dispatch) { |
|
| 764 | + ->then(function() use ($dispatch) { |
|
| 765 | 765 | return $dispatch->run(); |
| 766 | 766 | }); |
| 767 | 767 | } |
@@ -778,7 +778,7 @@ discard block |
||
| 778 | 778 | $closure = $this->config['route_check_cache_key']; |
| 779 | 779 | $routeKey = $closure($request); |
| 780 | 780 | } else { |
| 781 | - $routeKey = md5($request->baseUrl(true) . ':' . $request->method()); |
|
| 781 | + $routeKey = md5($request->baseUrl(true).':'.$request->method()); |
|
| 782 | 782 | } |
| 783 | 783 | |
| 784 | 784 | return $routeKey; |
@@ -828,10 +828,10 @@ discard block |
||
| 828 | 828 | $path = $pathinfo; |
| 829 | 829 | } elseif ($suffix) { |
| 830 | 830 | // 去除正常的URL后缀 |
| 831 | - $path = preg_replace('/\.(' . ltrim($suffix, '.') . ')$/i', '', $pathinfo); |
|
| 831 | + $path = preg_replace('/\.('.ltrim($suffix, '.').')$/i', '', $pathinfo); |
|
| 832 | 832 | } else { |
| 833 | 833 | // 允许任何后缀访问 |
| 834 | - $path = preg_replace('/\.' . $this->request->ext() . '$/i', '', $pathinfo); |
|
| 834 | + $path = preg_replace('/\.'.$this->request->ext().'$/i', '', $pathinfo); |
|
| 835 | 835 | } |
| 836 | 836 | |
| 837 | 837 | return $path; |
@@ -874,9 +874,9 @@ discard block |
||
| 874 | 874 | $item = $this->domains[$this->host]; |
| 875 | 875 | } elseif (isset($this->domains[$subDomain])) { |
| 876 | 876 | $item = $this->domains[$subDomain]; |
| 877 | - } elseif (isset($this->domains['*.' . $domain2]) && !empty($domain3)) { |
|
| 877 | + } elseif (isset($this->domains['*.'.$domain2]) && !empty($domain3)) { |
|
| 878 | 878 | // 泛三级域名 |
| 879 | - $item = $this->domains['*.' . $domain2]; |
|
| 879 | + $item = $this->domains['*.'.$domain2]; |
|
| 880 | 880 | $panDomain = $domain3; |
| 881 | 881 | } elseif (isset($this->domains['*']) && !empty($domain2)) { |
| 882 | 882 | // 泛二级域名 |
@@ -48,9 +48,9 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | if ($app) { |
| 51 | - $filename = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . $app . DIRECTORY_SEPARATOR . 'route_list.php'; |
|
| 51 | + $filename = $this->app->getRootPath().'runtime'.DIRECTORY_SEPARATOR.$app.DIRECTORY_SEPARATOR.'route_list.php'; |
|
| 52 | 52 | } else { |
| 53 | - $filename = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . 'route_list.php'; |
|
| 53 | + $filename = $this->app->getRootPath().'runtime'.DIRECTORY_SEPARATOR.'route_list.php'; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | if (is_file($filename)) { |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | $content = $this->getRouteList($app); |
| 63 | - file_put_contents($filename, 'Route List' . PHP_EOL . $content); |
|
| 63 | + file_put_contents($filename, 'Route List'.PHP_EOL.$content); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | protected function getRouteList(string $app = null): string |
@@ -69,16 +69,16 @@ discard block |
||
| 69 | 69 | $this->app->route->clear(); |
| 70 | 70 | |
| 71 | 71 | if ($app) { |
| 72 | - $path = $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR . $app . DIRECTORY_SEPARATOR; |
|
| 72 | + $path = $this->app->getRootPath().'route'.DIRECTORY_SEPARATOR.$app.DIRECTORY_SEPARATOR; |
|
| 73 | 73 | } else { |
| 74 | - $path = $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR; |
|
| 74 | + $path = $this->app->getRootPath().'route'.DIRECTORY_SEPARATOR; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | $files = is_dir($path) ? scandir($path) : []; |
| 78 | 78 | |
| 79 | 79 | foreach ($files as $file) { |
| 80 | 80 | if (strpos($file, '.php')) { |
| 81 | - include $path . $file; |
|
| 81 | + include $path.$file; |
|
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | $sort = $this->sortBy[$sort]; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - uasort($rows, function ($a, $b) use ($sort) { |
|
| 120 | + uasort($rows, function($a, $b) use ($sort) { |
|
| 121 | 121 | $itemA = $a[$sort] ?? null; |
| 122 | 122 | $itemB = $b[$sort] ?? null; |
| 123 | 123 | |
@@ -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 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | public function __construct(App $app) |
| 59 | 59 | { |
| 60 | 60 | $this->app = $app; |
| 61 | - $this->multi = is_dir($this->app->getBasePath() . 'controller') ? false : true; |
|
| 61 | + $this->multi = is_dir($this->app->getBasePath().'controller') ? false : true; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -191,14 +191,14 @@ discard block |
||
| 191 | 191 | |
| 192 | 192 | return $this->app->middleware->pipeline() |
| 193 | 193 | ->send($request) |
| 194 | - ->then(function ($request) { |
|
| 194 | + ->then(function($request) { |
|
| 195 | 195 | return $this->dispatchToRoute($request); |
| 196 | 196 | }); |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | protected function dispatchToRoute($request) |
| 200 | 200 | { |
| 201 | - $withRoute = $this->app->config->get('app.with_route', true) ? function () { |
|
| 201 | + $withRoute = $this->app->config->get('app.with_route', true) ? function() { |
|
| 202 | 202 | $this->loadRoutes(); |
| 203 | 203 | } : null; |
| 204 | 204 | |
@@ -210,8 +210,8 @@ discard block |
||
| 210 | 210 | */ |
| 211 | 211 | protected function loadMiddleware(): void |
| 212 | 212 | { |
| 213 | - if (is_file($this->app->getBasePath() . 'middleware.php')) { |
|
| 214 | - $this->app->middleware->import(include $this->app->getBasePath() . 'middleware.php'); |
|
| 213 | + if (is_file($this->app->getBasePath().'middleware.php')) { |
|
| 214 | + $this->app->middleware->import(include $this->app->getBasePath().'middleware.php'); |
|
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | $routePath = $this->getRoutePath(); |
| 227 | 227 | |
| 228 | 228 | if (is_dir($routePath)) { |
| 229 | - $files = glob($routePath . '*.php'); |
|
| 229 | + $files = glob($routePath.'*.php'); |
|
| 230 | 230 | foreach ($files as $file) { |
| 231 | 231 | include $file; |
| 232 | 232 | } |
@@ -242,11 +242,11 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | protected function getRoutePath(): string |
| 244 | 244 | { |
| 245 | - if ($this->isMulti() && is_dir($this->app->getAppPath() . 'route')) { |
|
| 246 | - return $this->app->getAppPath() . 'route' . DIRECTORY_SEPARATOR; |
|
| 245 | + if ($this->isMulti() && is_dir($this->app->getAppPath().'route')) { |
|
| 246 | + return $this->app->getAppPath().'route'.DIRECTORY_SEPARATOR; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - return $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR . ($this->isMulti() ? $this->getName() . DIRECTORY_SEPARATOR : ''); |
|
| 249 | + return $this->app->getRootPath().'route'.DIRECTORY_SEPARATOR.($this->isMulti() ? $this->getName().DIRECTORY_SEPARATOR : ''); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | $appName = $map[$name]; |
| 335 | 335 | } |
| 336 | 336 | } elseif ($name && (false !== array_search($name, $map) || in_array($name, $deny))) { |
| 337 | - throw new HttpException(404, 'app not exists:' . $name); |
|
| 337 | + throw new HttpException(404, 'app not exists:'.$name); |
|
| 338 | 338 | } elseif ($name && isset($map['*'])) { |
| 339 | 339 | $appName = $map['*']; |
| 340 | 340 | } else { |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | if ($name) { |
| 345 | - $this->app->request->setRoot('/' . $name); |
|
| 345 | + $this->app->request->setRoot('/'.$name); |
|
| 346 | 346 | $this->app->request->setPathinfo(strpos($path, '/') ? ltrim(strstr($path, '/'), '/') : ''); |
| 347 | 347 | } |
| 348 | 348 | } |
@@ -361,11 +361,11 @@ discard block |
||
| 361 | 361 | { |
| 362 | 362 | $this->name = $appName; |
| 363 | 363 | $this->app->request->setApp($appName); |
| 364 | - $this->app->setAppPath($this->path ?: $this->app->getBasePath() . $appName . DIRECTORY_SEPARATOR); |
|
| 365 | - $this->app->setRuntimePath($this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . $appName . DIRECTORY_SEPARATOR); |
|
| 364 | + $this->app->setAppPath($this->path ?: $this->app->getBasePath().$appName.DIRECTORY_SEPARATOR); |
|
| 365 | + $this->app->setRuntimePath($this->app->getRootPath().'runtime'.DIRECTORY_SEPARATOR.$appName.DIRECTORY_SEPARATOR); |
|
| 366 | 366 | |
| 367 | 367 | // 设置应用命名空间 |
| 368 | - $this->app->setNamespace($this->app->config->get('app.app_namespace') ?: 'app\\' . $appName); |
|
| 368 | + $this->app->setNamespace($this->app->config->get('app.app_namespace') ?: 'app\\'.$appName); |
|
| 369 | 369 | |
| 370 | 370 | //加载应用 |
| 371 | 371 | $this->loadApp($appName); |
@@ -382,34 +382,34 @@ discard block |
||
| 382 | 382 | if (is_dir($this->app->getAppPath())) { |
| 383 | 383 | $appPath = $this->app->getAppPath(); |
| 384 | 384 | |
| 385 | - if (is_file($appPath . 'common.php')) { |
|
| 386 | - include_once $appPath . 'common.php'; |
|
| 385 | + if (is_file($appPath.'common.php')) { |
|
| 386 | + include_once $appPath.'common.php'; |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | $configPath = $this->app->getConfigPath(); |
| 390 | 390 | |
| 391 | 391 | $files = []; |
| 392 | 392 | |
| 393 | - if (is_dir($appPath . 'config')) { |
|
| 394 | - $files = array_merge($files, glob($appPath . 'config' . DIRECTORY_SEPARATOR . '*' . $this->app->getConfigExt())); |
|
| 395 | - } elseif (is_dir($configPath . $appName)) { |
|
| 396 | - $files = array_merge($files, glob($configPath . $appName . DIRECTORY_SEPARATOR . '*' . $this->app->getConfigExt())); |
|
| 393 | + if (is_dir($appPath.'config')) { |
|
| 394 | + $files = array_merge($files, glob($appPath.'config'.DIRECTORY_SEPARATOR.'*'.$this->app->getConfigExt())); |
|
| 395 | + } elseif (is_dir($configPath.$appName)) { |
|
| 396 | + $files = array_merge($files, glob($configPath.$appName.DIRECTORY_SEPARATOR.'*'.$this->app->getConfigExt())); |
|
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | foreach ($files as $file) { |
| 400 | 400 | $this->app->config->load($file, pathinfo($file, PATHINFO_FILENAME)); |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | - if (is_file($appPath . 'event.php')) { |
|
| 404 | - $this->app->loadEvent(include $appPath . 'event.php'); |
|
| 403 | + if (is_file($appPath.'event.php')) { |
|
| 404 | + $this->app->loadEvent(include $appPath.'event.php'); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | - if (is_file($appPath . 'middleware.php')) { |
|
| 408 | - $this->app->middleware->import(include $appPath . 'middleware.php'); |
|
| 407 | + if (is_file($appPath.'middleware.php')) { |
|
| 408 | + $this->app->middleware->import(include $appPath.'middleware.php'); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - if (is_file($appPath . 'provider.php')) { |
|
| 412 | - $this->app->bind(include $appPath . 'provider.php'); |
|
| 411 | + if (is_file($appPath.'provider.php')) { |
|
| 412 | + $this->app->bind(include $appPath.'provider.php'); |
|
| 413 | 413 | } |
| 414 | 414 | } |
| 415 | 415 | |