| @@ -217,13 +217,13 @@ discard block | ||
| 217 | 217 | } | 
| 218 | 218 |          if (!$this->config->has('app.import')) { | 
| 219 | 219 |              $this->config->set('app.import', [ | 
| 220 | -                0 => \constant('NEBULA_APP').'/' .'share', | |
| 220 | +                0 => \constant('NEBULA_APP').'/'.'share', | |
| 221 | 221 | ]); | 
| 222 | 222 | } | 
| 223 | 223 | |
| 224 | 224 |          if (!$this->config->has('app.resource')) { | 
| 225 | 225 |              $this->config->set('app.resource', [ | 
| 226 | -                0 => \constant('NEBULA_APP').'/' .'resource', | |
| 226 | +                0 => \constant('NEBULA_APP').'/'.'resource', | |
| 227 | 227 | ]); | 
| 228 | 228 | } | 
| 229 | 229 | } | 
| @@ -235,7 +235,7 @@ discard block | ||
| 235 | 235 | */ | 
| 236 | 236 | public function run() | 
| 237 | 237 |      { | 
| 238 | -        $className  = $this->config->get('app.application', Application::class); | |
| 238 | +        $className = $this->config->get('app.application', Application::class); | |
| 239 | 239 | $this->application = Runnable::newClassInstance($className); | 
| 240 | 240 | $this->application->setNebula($this); | 
| 241 | 241 | $this->application->initiation(); | 
| @@ -9,9 +9,9 @@ discard block | ||
| 9 | 9 | */ | 
| 10 | 10 | abstract class ConfigLoader | 
| 11 | 11 |  { | 
| 12 | - public function loadConfig(string $path, array $extra =[]):?array | |
| 12 | + public function loadConfig(string $path, array $extra = []): ?array | |
| 13 | 13 |      { | 
| 14 | - $data=null; | |
| 14 | + $data = null; | |
| 15 | 15 |          if (!file_exists($path)) { | 
| 16 | 16 | $path = static::resolve($path); | 
| 17 | 17 | } | 
| @@ -27,25 +27,25 @@ discard block | ||
| 27 | 27 | return $data; | 
| 28 | 28 | } | 
| 29 | 29 | |
| 30 | - protected function loadJson(string $path, array $extra =[]):array | |
| 30 | + protected function loadJson(string $path, array $extra = []):array | |
| 31 | 31 |      { | 
| 32 | 32 | $content = file_get_contents($path); | 
| 33 | - $content =$this->parseValue($content, $extra); | |
| 33 | + $content = $this->parseValue($content, $extra); | |
| 34 | 34 | $data = json_decode($content, true); | 
| 35 | -        if (json_last_error()!==JSON_ERROR_NONE) { | |
| 35 | +        if (json_last_error() !== JSON_ERROR_NONE) { | |
| 36 | 36 | throw new JSONException(json_last_error()); | 
| 37 | 37 | } | 
| 38 | 38 | return $data; | 
| 39 | 39 | } | 
| 40 | 40 | |
| 41 | - protected function loadIni(string $path, array $extra =[]):array | |
| 41 | + protected function loadIni(string $path, array $extra = []):array | |
| 42 | 42 |      { | 
| 43 | 43 | $content = file_get_contents($path); | 
| 44 | - $content =$this->parseValue($content, $extra); | |
| 44 | + $content = $this->parseValue($content, $extra); | |
| 45 | 45 | return \parse_ini_string($content, true) ?: []; | 
| 46 | 46 | } | 
| 47 | 47 | |
| 48 | - protected function loadYaml(string $path, array $extra =[]):array | |
| 48 | + protected function loadYaml(string $path, array $extra = []):array | |
| 49 | 49 |      { | 
| 50 | 50 |          if (function_exists('yaml_parse')) { | 
| 51 | 51 | $name = 'yaml_parse'; | 
| @@ -55,25 +55,25 @@ discard block | ||
| 55 | 55 |              throw new YamlException("parse yaml config error : missing yaml extension or spyc", 1); | 
| 56 | 56 | } | 
| 57 | 57 | $content = file_get_contents($path); | 
| 58 | - $content =$this->parseValue($content, $extra); | |
| 58 | + $content = $this->parseValue($content, $extra); | |
| 59 | 59 | return \call_user_func_array($name, [$content]); | 
| 60 | 60 | } | 
| 61 | 61 | |
| 62 | - abstract public function parseValue(string $content, array $extra =[]):string; | |
| 62 | + abstract public function parseValue(string $content, array $extra = []):string; | |
| 63 | 63 | |
| 64 | - public static function resolve(string $path):?string | |
| 64 | + public static function resolve(string $path): ?string | |
| 65 | 65 |      { | 
| 66 | 66 |          if (file_exists($path)) { | 
| 67 | 67 | return $path; | 
| 68 | 68 | } | 
| 69 | 69 | $basepath = pathinfo($path, PATHINFO_FILENAME); | 
| 70 | -        if (file_exists($conf = $basepath.'.yml')  || file_exists($conf = $basepath.'.yaml')) { | |
| 70 | +        if (file_exists($conf = $basepath.'.yml') || file_exists($conf = $basepath.'.yaml')) { | |
| 71 | 71 |              if (function_exists('yaml_parse') || class_exists('Spyc')) { | 
| 72 | 72 | return $conf; | 
| 73 | 73 | } | 
| 74 | 74 | } | 
| 75 | -        foreach (['.json','.php','.ini'] as $ext) { | |
| 76 | -            if (file_exists($conf=$basepath.$ext)) { | |
| 75 | +        foreach (['.json', '.php', '.ini'] as $ext) { | |
| 76 | +            if (file_exists($conf = $basepath.$ext)) { | |
| 77 | 77 | return $conf; | 
| 78 | 78 | } | 
| 79 | 79 | } | 
| @@ -28,7 +28,7 @@ discard block | ||
| 28 | 28 |      { | 
| 29 | 29 | $path = $source; | 
| 30 | 30 |          if (Path::isRelativePath($source)) { | 
| 31 | - $path = $relative.'/'.$path; | |
| 31 | + $path = $relative.'/'.$path; | |
| 32 | 32 | } | 
| 33 | 33 | return Path::toAbsolutePath($path); | 
| 34 | 34 | } | 
| @@ -53,7 +53,7 @@ discard block | ||
| 53 | 53 | * @param string $path | 
| 54 | 54 | * @return string|null | 
| 55 | 55 | */ | 
| 56 | - public function getResourcePath(string $path):?string | |
| 56 | + public function getResourcePath(string $path): ?string | |
| 57 | 57 |      { | 
| 58 | 58 |          foreach ($this->resource as $root) { | 
| 59 | 59 | $target = $root.'/'.$path; | 
| @@ -70,10 +70,10 @@ discard block | ||
| 70 | 70 | * @param string $path | 
| 71 | 71 | * @return string|null | 
| 72 | 72 | */ | 
| 73 | - public function getConfigResourcePath(string $path):?string | |
| 73 | + public function getConfigResourcePath(string $path): ?string | |
| 74 | 74 |      { | 
| 75 | 75 |          foreach ($this->resource as $root) { | 
| 76 | -            if ( $target = Config::resolve($root.'/'.$path)) { | |
| 76 | +            if ($target = Config::resolve($root.'/'.$path)) { | |
| 77 | 77 | return $target; | 
| 78 | 78 | } | 
| 79 | 79 | } | 
| @@ -4,9 +4,9 @@ | ||
| 4 | 4 |  defined('NEBULA_SYSTEM') or define('NEBULA_SYSTEM', dirname(__DIR__)); | 
| 5 | 5 |  defined('NEBULA_RESOURCE') or define('NEBULA_RESOURCE', dirname(__DIR__).'/resource'); | 
| 6 | 6 | |
| 7 | -require_once NEBULA_SYSTEM .'/src/component/loader/Path.php'; | |
| 8 | -require_once NEBULA_SYSTEM .'/src/component/loader/PathTrait.php'; | |
| 9 | -require_once NEBULA_SYSTEM .'/src/component/loader/PathInterface.php'; | |
| 10 | -require_once NEBULA_SYSTEM .'/src/component/loader/IncludeManager.php'; | |
| 11 | -require_once NEBULA_SYSTEM .'/src/component/loader/Loader.php'; | |
| 12 | -require_once NEBULA_SYSTEM .'/src/application/Loader.php'; | |
| 7 | +require_once NEBULA_SYSTEM.'/src/component/loader/Path.php'; | |
| 8 | +require_once NEBULA_SYSTEM.'/src/component/loader/PathTrait.php'; | |
| 9 | +require_once NEBULA_SYSTEM.'/src/component/loader/PathInterface.php'; | |
| 10 | +require_once NEBULA_SYSTEM.'/src/component/loader/IncludeManager.php'; | |
| 11 | +require_once NEBULA_SYSTEM.'/src/component/loader/Loader.php'; | |
| 12 | +require_once NEBULA_SYSTEM.'/src/application/Loader.php'; | |
| @@ -3,7 +3,7 @@ discard block | ||
| 3 | 3 | use nebula\NebulaApplication; | 
| 4 | 4 | use nebula\application\Loader; | 
| 5 | 5 | |
| 6 | -require_once __DIR__ .'/loader.php'; | |
| 6 | +require_once __DIR__.'/loader.php'; | |
| 7 | 7 | |
| 8 | 8 | |
| 9 | 9 | |
| @@ -11,7 +11,7 @@ discard block | ||
| 11 | 11 | |
| 12 | 12 | $loader = new Loader; | 
| 13 | 13 | $loader->register(); | 
| 14 | -$loader->addIncludePath(NEBULA_SYSTEM .'/src', 'nebula'); | |
| 14 | +$loader->addIncludePath(NEBULA_SYSTEM.'/src', 'nebula'); | |
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 |  $nebula = NebulaApplication::configuration(constant('NEBULA_APP')); |