@@ -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 | |
@@ -155,13 +155,13 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function __construct(string $rootPath = '') |
157 | 157 | { |
158 | - $this->thinkPath = dirname(__DIR__) . DIRECTORY_SEPARATOR; |
|
159 | - $this->rootPath = $rootPath ? rtrim($rootPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR : $this->getDefaultRootPath(); |
|
160 | - $this->appPath = $this->rootPath . 'app' . DIRECTORY_SEPARATOR; |
|
161 | - $this->runtimePath = $this->rootPath . 'runtime' . DIRECTORY_SEPARATOR; |
|
158 | + $this->thinkPath = dirname(__DIR__).DIRECTORY_SEPARATOR; |
|
159 | + $this->rootPath = $rootPath ? rtrim($rootPath, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR : $this->getDefaultRootPath(); |
|
160 | + $this->appPath = $this->rootPath.'app'.DIRECTORY_SEPARATOR; |
|
161 | + $this->runtimePath = $this->rootPath.'runtime'.DIRECTORY_SEPARATOR; |
|
162 | 162 | |
163 | - if (is_file($this->appPath . 'provider.php')) { |
|
164 | - $this->bind(include $this->appPath . 'provider.php'); |
|
163 | + if (is_file($this->appPath.'provider.php')) { |
|
164 | + $this->bind(include $this->appPath.'provider.php'); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | static::setInstance($this); |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | public function getService($service) |
222 | 222 | { |
223 | 223 | $name = is_string($service) ? $service : get_class($service); |
224 | - return array_values(array_filter($this->services, function ($value) use ($name) { |
|
224 | + return array_values(array_filter($this->services, function($value) use ($name) { |
|
225 | 225 | return $value instanceof $name; |
226 | 226 | }, ARRAY_FILTER_USE_BOTH))[0] ?? null; |
227 | 227 | } |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | */ |
298 | 298 | public function getBasePath(): string |
299 | 299 | { |
300 | - return $this->rootPath . 'app' . DIRECTORY_SEPARATOR; |
|
300 | + return $this->rootPath.'app'.DIRECTORY_SEPARATOR; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | */ |
356 | 356 | public function getConfigPath(): string |
357 | 357 | { |
358 | - return $this->rootPath . 'config' . DIRECTORY_SEPARATOR; |
|
358 | + return $this->rootPath.'config'.DIRECTORY_SEPARATOR; |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
@@ -401,8 +401,8 @@ discard block |
||
401 | 401 | $this->beginMem = memory_get_usage(); |
402 | 402 | |
403 | 403 | // 加载环境变量 |
404 | - if (is_file($this->rootPath . '.env')) { |
|
405 | - $this->env->load($this->rootPath . '.env'); |
|
404 | + if (is_file($this->rootPath.'.env')) { |
|
405 | + $this->env->load($this->rootPath.'.env'); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | $this->configExt = $this->env->get('config_ext', '.php'); |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | // 加载框架默认语言包 |
416 | 416 | $langSet = $this->lang->defaultLangSet(); |
417 | 417 | |
418 | - $this->lang->load($this->thinkPath . 'lang' . DIRECTORY_SEPARATOR . $langSet . '.php'); |
|
418 | + $this->lang->load($this->thinkPath.'lang'.DIRECTORY_SEPARATOR.$langSet.'.php'); |
|
419 | 419 | |
420 | 420 | // 加载应用默认语言包 |
421 | 421 | $this->loadLangPack($langSet); |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | } |
455 | 455 | |
456 | 456 | // 加载系统语言包 |
457 | - $files = glob($this->appPath . 'lang' . DIRECTORY_SEPARATOR . $langset . '.*'); |
|
457 | + $files = glob($this->appPath.'lang'.DIRECTORY_SEPARATOR.$langset.'.*'); |
|
458 | 458 | $this->lang->load($files); |
459 | 459 | |
460 | 460 | // 加载扩展(自定义)语言包 |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | */ |
473 | 473 | public function boot(): void |
474 | 474 | { |
475 | - array_walk($this->services, function ($service) { |
|
475 | + array_walk($this->services, function($service) { |
|
476 | 476 | $this->bootService($service); |
477 | 477 | }); |
478 | 478 | } |
@@ -486,30 +486,30 @@ discard block |
||
486 | 486 | { |
487 | 487 | $appPath = $this->getAppPath(); |
488 | 488 | |
489 | - if (is_file($appPath . 'common.php')) { |
|
490 | - include_once $appPath . 'common.php'; |
|
489 | + if (is_file($appPath.'common.php')) { |
|
490 | + include_once $appPath.'common.php'; |
|
491 | 491 | } |
492 | 492 | |
493 | - include_once $this->thinkPath . 'helper.php'; |
|
493 | + include_once $this->thinkPath.'helper.php'; |
|
494 | 494 | |
495 | 495 | $configPath = $this->getConfigPath(); |
496 | 496 | |
497 | 497 | $files = []; |
498 | 498 | |
499 | 499 | if (is_dir($configPath)) { |
500 | - $files = glob($configPath . '*' . $this->configExt); |
|
500 | + $files = glob($configPath.'*'.$this->configExt); |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | foreach ($files as $file) { |
504 | 504 | $this->config->load($file, pathinfo($file, PATHINFO_FILENAME)); |
505 | 505 | } |
506 | 506 | |
507 | - if (is_file($appPath . 'event.php')) { |
|
508 | - $this->loadEvent(include $appPath . 'event.php'); |
|
507 | + if (is_file($appPath.'event.php')) { |
|
508 | + $this->loadEvent(include $appPath.'event.php'); |
|
509 | 509 | } |
510 | 510 | |
511 | - if (is_file($appPath . 'service.php')) { |
|
512 | - $services = include $appPath . 'service.php'; |
|
511 | + if (is_file($appPath.'service.php')) { |
|
512 | + $services = include $appPath.'service.php'; |
|
513 | 513 | foreach ($services as $service) { |
514 | 514 | $this->register($service); |
515 | 515 | } |
@@ -574,9 +574,9 @@ discard block |
||
574 | 574 | $name = str_replace(['/', '.'], '\\', $name); |
575 | 575 | $array = explode('\\', $name); |
576 | 576 | $class = Str::studly(array_pop($array)); |
577 | - $path = $array ? implode('\\', $array) . '\\' : ''; |
|
577 | + $path = $array ? implode('\\', $array).'\\' : ''; |
|
578 | 578 | |
579 | - return $this->namespace . '\\' . $layer . '\\' . $path . $class; |
|
579 | + return $this->namespace.'\\'.$layer.'\\'.$path.$class; |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | /** |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | { |
598 | 598 | $path = dirname(dirname(dirname(dirname($this->thinkPath)))); |
599 | 599 | |
600 | - return $path . DIRECTORY_SEPARATOR; |
|
600 | + return $path.DIRECTORY_SEPARATOR; |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | } |
@@ -29,14 +29,14 @@ discard block |
||
29 | 29 | { |
30 | 30 | $app = $input->getArgument('app'); |
31 | 31 | |
32 | - if (empty($app) && !is_dir($this->app->getBasePath() . 'controller')) { |
|
32 | + if (empty($app) && !is_dir($this->app->getBasePath().'controller')) { |
|
33 | 33 | $output->writeln('<error>Miss app name!</error>'); |
34 | 34 | return false; |
35 | 35 | } |
36 | 36 | |
37 | - $path = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . ($app ? $app . DIRECTORY_SEPARATOR : ''); |
|
37 | + $path = $this->app->getRootPath().'runtime'.DIRECTORY_SEPARATOR.($app ? $app.DIRECTORY_SEPARATOR : ''); |
|
38 | 38 | |
39 | - $filename = $path . 'route.php'; |
|
39 | + $filename = $path.'route.php'; |
|
40 | 40 | if (is_file($filename)) { |
41 | 41 | unlink($filename); |
42 | 42 | } |
@@ -51,21 +51,21 @@ discard block |
||
51 | 51 | $this->app->route->lazy(false); |
52 | 52 | |
53 | 53 | // 路由检测 |
54 | - $path = $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR . ($app ? $app . DIRECTORY_SEPARATOR : ''); |
|
54 | + $path = $this->app->getRootPath().'route'.DIRECTORY_SEPARATOR.($app ? $app.DIRECTORY_SEPARATOR : ''); |
|
55 | 55 | |
56 | 56 | $files = is_dir($path) ? scandir($path) : []; |
57 | 57 | |
58 | 58 | foreach ($files as $file) { |
59 | 59 | if (strpos($file, '.php')) { |
60 | - include $path . $file; |
|
60 | + include $path.$file; |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | 64 | //触发路由载入完成事件 |
65 | 65 | $this->app->event->trigger(RouteLoaded::class); |
66 | 66 | |
67 | - $content = '<?php ' . PHP_EOL . 'return '; |
|
68 | - $content .= '\Opis\Closure\unserialize(\'' . \Opis\Closure\serialize($this->app->route->getName()) . '\');'; |
|
67 | + $content = '<?php '.PHP_EOL.'return '; |
|
68 | + $content .= '\Opis\Closure\unserialize(\''.\Opis\Closure\serialize($this->app->route->getName()).'\');'; |
|
69 | 69 | return $content; |
70 | 70 | } |
71 | 71 |