@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | public function __construct($appPath = '') |
128 | 128 | { |
129 | - $this->thinkPath = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR; |
|
129 | + $this->thinkPath = dirname(dirname(__DIR__)).DIRECTORY_SEPARATOR; |
|
130 | 130 | $this->path($appPath); |
131 | 131 | } |
132 | 132 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function path($path) |
152 | 152 | { |
153 | - $this->appPath = $path ? realpath($path) . DIRECTORY_SEPARATOR : $this->getAppPath(); |
|
153 | + $this->appPath = $path ? realpath($path).DIRECTORY_SEPARATOR : $this->getAppPath(); |
|
154 | 154 | |
155 | 155 | return $this; |
156 | 156 | } |
@@ -170,24 +170,24 @@ discard block |
||
170 | 170 | $this->beginTime = microtime(true); |
171 | 171 | $this->beginMem = memory_get_usage(); |
172 | 172 | |
173 | - $this->rootPath = dirname($this->appPath) . DIRECTORY_SEPARATOR; |
|
174 | - $this->runtimePath = $this->rootPath . 'runtime' . DIRECTORY_SEPARATOR; |
|
175 | - $this->routePath = $this->rootPath . 'route' . DIRECTORY_SEPARATOR; |
|
176 | - $this->configPath = $this->rootPath . 'config' . DIRECTORY_SEPARATOR; |
|
173 | + $this->rootPath = dirname($this->appPath).DIRECTORY_SEPARATOR; |
|
174 | + $this->runtimePath = $this->rootPath.'runtime'.DIRECTORY_SEPARATOR; |
|
175 | + $this->routePath = $this->rootPath.'route'.DIRECTORY_SEPARATOR; |
|
176 | + $this->configPath = $this->rootPath.'config'.DIRECTORY_SEPARATOR; |
|
177 | 177 | |
178 | 178 | static::setInstance($this); |
179 | 179 | |
180 | 180 | $this->instance('app', $this); |
181 | 181 | |
182 | 182 | // 加载环境变量配置文件 |
183 | - if (is_file($this->rootPath . '.env')) { |
|
184 | - $this->env->load($this->rootPath . '.env'); |
|
183 | + if (is_file($this->rootPath.'.env')) { |
|
184 | + $this->env->load($this->rootPath.'.env'); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | $this->configExt = $this->env->get('config_ext', '.php'); |
188 | 188 | |
189 | 189 | // 加载惯例配置文件 |
190 | - $this->config->set(include $this->thinkPath . 'convention.php'); |
|
190 | + $this->config->set(include $this->thinkPath.'convention.php'); |
|
191 | 191 | |
192 | 192 | // 设置路径环境变量 |
193 | 193 | $this->env->set([ |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | 'config_path' => $this->configPath, |
198 | 198 | 'route_path' => $this->routePath, |
199 | 199 | 'runtime_path' => $this->runtimePath, |
200 | - 'extend_path' => $this->rootPath . 'extend' . DIRECTORY_SEPARATOR, |
|
201 | - 'vendor_path' => $this->rootPath . 'vendor' . DIRECTORY_SEPARATOR, |
|
200 | + 'extend_path' => $this->rootPath.'extend'.DIRECTORY_SEPARATOR, |
|
201 | + 'vendor_path' => $this->rootPath.'vendor'.DIRECTORY_SEPARATOR, |
|
202 | 202 | ]); |
203 | 203 | |
204 | 204 | $this->namespace = $this->env->get('app_namespace', $this->namespace); |
@@ -268,61 +268,61 @@ discard block |
||
268 | 268 | public function init($module = '') |
269 | 269 | { |
270 | 270 | // 定位模块目录 |
271 | - $module = $module ? $module . DIRECTORY_SEPARATOR : ''; |
|
272 | - $path = $this->appPath . $module; |
|
271 | + $module = $module ? $module.DIRECTORY_SEPARATOR : ''; |
|
272 | + $path = $this->appPath.$module; |
|
273 | 273 | |
274 | 274 | // 加载初始化文件 |
275 | - if (is_file($path . 'init.php')) { |
|
276 | - include $path . 'init.php'; |
|
277 | - } elseif (is_file($this->runtimePath . $module . 'init.php')) { |
|
278 | - include $this->runtimePath . $module . 'init.php'; |
|
275 | + if (is_file($path.'init.php')) { |
|
276 | + include $path.'init.php'; |
|
277 | + } elseif (is_file($this->runtimePath.$module.'init.php')) { |
|
278 | + include $this->runtimePath.$module.'init.php'; |
|
279 | 279 | } else { |
280 | 280 | // 加载行为扩展文件 |
281 | - if (is_file($path . 'tags.php')) { |
|
282 | - $tags = include $path . 'tags.php'; |
|
281 | + if (is_file($path.'tags.php')) { |
|
282 | + $tags = include $path.'tags.php'; |
|
283 | 283 | if (is_array($tags)) { |
284 | 284 | $this->hook->import($tags); |
285 | 285 | } |
286 | 286 | } |
287 | 287 | |
288 | 288 | // 加载公共文件 |
289 | - if (is_file($path . 'common.php')) { |
|
290 | - include_once $path . 'common.php'; |
|
289 | + if (is_file($path.'common.php')) { |
|
290 | + include_once $path.'common.php'; |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | if ('' == $module) { |
294 | 294 | // 加载系统助手函数 |
295 | - include $this->thinkPath . 'helper.php'; |
|
295 | + include $this->thinkPath.'helper.php'; |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | // 加载中间件 |
299 | - if (is_file($path . 'middleware.php')) { |
|
300 | - $middleware = include $path . 'middleware.php'; |
|
299 | + if (is_file($path.'middleware.php')) { |
|
300 | + $middleware = include $path.'middleware.php'; |
|
301 | 301 | if (is_array($middleware)) { |
302 | 302 | $this->middleware->import($middleware); |
303 | 303 | } |
304 | 304 | } |
305 | 305 | |
306 | 306 | // 注册服务的容器对象实例 |
307 | - if (is_file($path . 'provider.php')) { |
|
308 | - $provider = include $path . 'provider.php'; |
|
307 | + if (is_file($path.'provider.php')) { |
|
308 | + $provider = include $path.'provider.php'; |
|
309 | 309 | if (is_array($provider)) { |
310 | 310 | $this->bindTo($provider); |
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | 314 | // 自动读取配置文件 |
315 | - if (is_dir($path . 'config')) { |
|
316 | - $dir = $path . 'config' . DIRECTORY_SEPARATOR; |
|
317 | - } elseif (is_dir($this->configPath . $module)) { |
|
318 | - $dir = $this->configPath . $module; |
|
315 | + if (is_dir($path.'config')) { |
|
316 | + $dir = $path.'config'.DIRECTORY_SEPARATOR; |
|
317 | + } elseif (is_dir($this->configPath.$module)) { |
|
318 | + $dir = $this->configPath.$module; |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | $files = isset($dir) ? scandir($dir) : []; |
322 | 322 | |
323 | 323 | foreach ($files as $file) { |
324 | - if ('.' . pathinfo($file, PATHINFO_EXTENSION) === $this->configExt) { |
|
325 | - $this->config->load($dir . $file, pathinfo($file, PATHINFO_FILENAME)); |
|
324 | + if ('.'.pathinfo($file, PATHINFO_EXTENSION) === $this->configExt) { |
|
325 | + $this->config->load($dir.$file, pathinfo($file, PATHINFO_FILENAME)); |
|
326 | 326 | } |
327 | 327 | } |
328 | 328 | } |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | $this->cache->init($config['cache'], true); |
357 | 357 | |
358 | 358 | // 加载当前模块语言包 |
359 | - $this->lang->load($this->appPath . $module . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . $this->request->langset() . '.php'); |
|
359 | + $this->lang->load($this->appPath.$module.DIRECTORY_SEPARATOR.'lang'.DIRECTORY_SEPARATOR.$this->request->langset().'.php'); |
|
360 | 360 | |
361 | 361 | // 模块请求缓存检查 |
362 | 362 | $this->checkRequestCache( |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | } elseif ($this->config('app.auto_bind_module')) { |
388 | 388 | // 入口自动绑定 |
389 | 389 | $name = pathinfo($this->request->baseFile(), PATHINFO_FILENAME); |
390 | - if ($name && 'index' != $name && is_dir($this->appPath . $name)) { |
|
390 | + if ($name && 'index' != $name && is_dir($this->appPath.$name)) { |
|
391 | 391 | $this->route->bind($name); |
392 | 392 | } |
393 | 393 | } |
@@ -407,9 +407,9 @@ discard block |
||
407 | 407 | |
408 | 408 | // 记录路由和请求信息 |
409 | 409 | if ($this->appDebug) { |
410 | - $this->log('[ ROUTE ] ' . var_export($this->request->routeInfo(), true)); |
|
411 | - $this->log('[ HEADER ] ' . var_export($this->request->header(), true)); |
|
412 | - $this->log('[ PARAM ] ' . var_export($this->request->param(), true)); |
|
410 | + $this->log('[ ROUTE ] '.var_export($this->request->routeInfo(), true)); |
|
411 | + $this->log('[ HEADER ] '.var_export($this->request->header(), true)); |
|
412 | + $this->log('[ PARAM ] '.var_export($this->request->param(), true)); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | // 监听app_begin |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | $data = $exception->getResponse(); |
429 | 429 | } |
430 | 430 | |
431 | - $this->middleware->add(function (Request $request, $next) use ($dispatch, $data) { |
|
431 | + $this->middleware->add(function(Request $request, $next) use ($dispatch, $data) { |
|
432 | 432 | return is_null($data) ? $dispatch->run() : $data; |
433 | 433 | }); |
434 | 434 | |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | $closure = $this->config->get('route_check_cache_key'); |
447 | 447 | $routeKey = $closure($this->request); |
448 | 448 | } else { |
449 | - $routeKey = md5($this->request->baseUrl(true) . ':' . $this->request->method()); |
|
449 | + $routeKey = md5($this->request->baseUrl(true).':'.$this->request->method()); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | return $routeKey; |
@@ -466,8 +466,8 @@ discard block |
||
466 | 466 | |
467 | 467 | // 加载系统语言包 |
468 | 468 | $this->lang->load([ |
469 | - $this->thinkPath . 'lang' . DIRECTORY_SEPARATOR . $this->request->langset() . '.php', |
|
470 | - $this->appPath . 'lang' . DIRECTORY_SEPARATOR . $this->request->langset() . '.php', |
|
469 | + $this->thinkPath.'lang'.DIRECTORY_SEPARATOR.$this->request->langset().'.php', |
|
470 | + $this->appPath.'lang'.DIRECTORY_SEPARATOR.$this->request->langset().'.php', |
|
471 | 471 | ]); |
472 | 472 | } |
473 | 473 | |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | { |
550 | 550 | // 路由检测 |
551 | 551 | if (is_dir($this->routePath)) { |
552 | - $files = glob($this->routePath . '*.php'); |
|
552 | + $files = glob($this->routePath.'*.php'); |
|
553 | 553 | foreach ($files as $file) { |
554 | 554 | $rules = include $file; |
555 | 555 | if (is_array($rules)) { |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | $this->build->buildRoute($suffix); |
566 | 566 | } |
567 | 567 | |
568 | - $filename = $this->runtimePath . 'build_route.php'; |
|
568 | + $filename = $this->runtimePath.'build_route.php'; |
|
569 | 569 | |
570 | 570 | if (is_file($filename)) { |
571 | 571 | include $filename; |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | */ |
667 | 667 | public function create($name, $layer, $appendSuffix = false, $common = 'common') |
668 | 668 | { |
669 | - $guid = $name . $layer; |
|
669 | + $guid = $name.$layer; |
|
670 | 670 | |
671 | 671 | if ($this->__isset($guid)) { |
672 | 672 | return $this->__get($guid); |
@@ -677,11 +677,11 @@ discard block |
||
677 | 677 | if (class_exists($class)) { |
678 | 678 | $object = $this->__get($class); |
679 | 679 | } else { |
680 | - $class = str_replace('\\' . $module . '\\', '\\' . $common . '\\', $class); |
|
680 | + $class = str_replace('\\'.$module.'\\', '\\'.$common.'\\', $class); |
|
681 | 681 | if (class_exists($class)) { |
682 | 682 | $object = $this->__get($class); |
683 | 683 | } else { |
684 | - throw new ClassNotFoundException('class not exists:' . $class, $class); |
|
684 | + throw new ClassNotFoundException('class not exists:'.$class, $class); |
|
685 | 685 | } |
686 | 686 | } |
687 | 687 | |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | return $this->make($emptyClass, true); |
726 | 726 | } |
727 | 727 | |
728 | - throw new ClassNotFoundException('class not exists:' . $class, $class); |
|
728 | + throw new ClassNotFoundException('class not exists:'.$class, $class); |
|
729 | 729 | } |
730 | 730 | |
731 | 731 | /** |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | } |
787 | 787 | } |
788 | 788 | |
789 | - return $this->invokeMethod([$class, $action . $this->config('action_suffix')], $vars); |
|
789 | + return $this->invokeMethod([$class, $action.$this->config('action_suffix')], $vars); |
|
790 | 790 | } |
791 | 791 | |
792 | 792 | /** |
@@ -802,10 +802,10 @@ discard block |
||
802 | 802 | { |
803 | 803 | $name = str_replace(['/', '.'], '\\', $name); |
804 | 804 | $array = explode('\\', $name); |
805 | - $class = Loader::parseName(array_pop($array), 1) . ($this->suffix || $appendSuffix ? ucfirst($layer) : ''); |
|
806 | - $path = $array ? implode('\\', $array) . '\\' : ''; |
|
805 | + $class = Loader::parseName(array_pop($array), 1).($this->suffix || $appendSuffix ? ucfirst($layer) : ''); |
|
806 | + $path = $array ? implode('\\', $array).'\\' : ''; |
|
807 | 807 | |
808 | - return $this->namespace . '\\' . ($module ? $module . '\\' : '') . $layer . '\\' . $path . $class; |
|
808 | + return $this->namespace.'\\'.($module ? $module.'\\' : '').$layer.'\\'.$path.$class; |
|
809 | 809 | } |
810 | 810 | |
811 | 811 | /** |
@@ -868,7 +868,7 @@ discard block |
||
868 | 868 | public function getAppPath() |
869 | 869 | { |
870 | 870 | if (is_null($this->appPath)) { |
871 | - $this->appPath = Loader::getRootPath() . 'application' . DIRECTORY_SEPARATOR; |
|
871 | + $this->appPath = Loader::getRootPath().'application'.DIRECTORY_SEPARATOR; |
|
872 | 872 | } |
873 | 873 | |
874 | 874 | return $this->appPath; |