@@ -11,9 +11,9 @@ discard block |
||
| 11 | 11 | * |
| 12 | 12 | * @var array |
| 13 | 13 | */ |
| 14 | - protected $attribute=[]; |
|
| 14 | + protected $attribute = []; |
|
| 15 | 15 | |
| 16 | - public function addAttribute(string $name , $value) |
|
| 16 | + public function addAttribute(string $name, $value) |
|
| 17 | 17 | { |
| 18 | 18 | $this->attribute[$name] = $value; |
| 19 | 19 | } |
@@ -21,10 +21,10 @@ discard block |
||
| 21 | 21 | protected function analyse(array $context) |
| 22 | 22 | { |
| 23 | 23 | $replace = []; |
| 24 | - $attach =[] ; |
|
| 24 | + $attach = []; |
|
| 25 | 25 | foreach ($context as $key => $val) { |
| 26 | - if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString')) && ! $val instanceof \Exception) { |
|
| 27 | - $replace['{' . $key . '}'] = $val; |
|
| 26 | + if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString')) && !$val instanceof \Exception) { |
|
| 27 | + $replace['{'.$key.'}'] = $val; |
|
| 28 | 28 | } else { |
| 29 | 29 | $attach[$key] = $val; |
| 30 | 30 | } |
@@ -34,19 +34,19 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | public function interpolate(string $message, array $context, array $attribute) |
| 36 | 36 | { |
| 37 | - list($attach, $replace) = $this->analyse($context); |
|
| 37 | + list($attach, $replace) = $this->analyse($context); |
|
| 38 | 38 | $attribute = array_merge($this->attribute, $attribute); |
| 39 | 39 | foreach ($attribute as $key => $val) { |
| 40 | - $replace['%' . $key . '%'] = $val; |
|
| 40 | + $replace['%'.$key.'%'] = $val; |
|
| 41 | 41 | } |
| 42 | 42 | $message = strtr($message, $replace); |
| 43 | 43 | $attachInfo = ''; |
| 44 | 44 | foreach ($attach as $name => $value) { |
| 45 | 45 | $attachInfo = $name.' = '; |
| 46 | 46 | if ($value instanceof AttachValueInterface) { |
| 47 | - $attachInfo.= $value->getLogAttach().PHP_EOL; |
|
| 47 | + $attachInfo .= $value->getLogAttach().PHP_EOL; |
|
| 48 | 48 | } else { |
| 49 | - $attachInfo.= DumpTrait::parameterToString($value).PHP_EOL; |
|
| 49 | + $attachInfo .= DumpTrait::parameterToString($value).PHP_EOL; |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | if (strlen($attachInfo) > 0) { |
@@ -95,17 +95,17 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | if (!$this->config->has('app.import')) { |
| 97 | 97 | $this->config->set('app.import', [ |
| 98 | - 0 => \constant('NEBULA_APP').'/' .'share', |
|
| 98 | + 0 => \constant('NEBULA_APP').'/'.'share', |
|
| 99 | 99 | ]); |
| 100 | 100 | } |
| 101 | 101 | if (!$this->config->has('app.resource')) { |
| 102 | 102 | $this->config->set('app.resource', [ |
| 103 | - 0 => \constant('NEBULA_APP').'/' .'resource', |
|
| 103 | + 0 => \constant('NEBULA_APP').'/'.'resource', |
|
| 104 | 104 | ]); |
| 105 | 105 | } |
| 106 | 106 | if (!$this->config->has('app.module.scan-path')) { |
| 107 | 107 | $this->config->set('app.module.scan-path', [ |
| 108 | - 0 => \constant('NEBULA_APP').'/' .'modules', |
|
| 108 | + 0 => \constant('NEBULA_APP').'/'.'modules', |
|
| 109 | 109 | ]); |
| 110 | 110 | } |
| 111 | 111 | } |
@@ -121,9 +121,9 @@ discard block |
||
| 121 | 121 | $logger = (new Runnable($this->getConfig()->get('app.logger-build', [$this, 'buildLogger'])))->run(); |
| 122 | 122 | $debugger = new Debugger; |
| 123 | 123 | |
| 124 | - $debugger->addAttribute('remote-ip' , $this->getRequest()->ip() ); |
|
| 125 | - $debugger->addAttribute('request-uri' , $this->getRequest()->getUrl()); |
|
| 126 | - $debugger->addAttribute('request-method' , $this->getRequest()->getMethod()); |
|
| 124 | + $debugger->addAttribute('remote-ip', $this->getRequest()->ip()); |
|
| 125 | + $debugger->addAttribute('request-uri', $this->getRequest()->getUrl()); |
|
| 126 | + $debugger->addAttribute('request-method', $this->getRequest()->getMethod()); |
|
| 127 | 127 | |
| 128 | 128 | $debugger->applyConfig([ |
| 129 | 129 | 'start-time' => \constant('NEBULA_START_TIME'), |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | public function run() |
| 191 | 191 | { |
| 192 | - $className = $this->config->get('app.application', Application::class); |
|
| 192 | + $className = $this->config->get('app.application', Application::class); |
|
| 193 | 193 | $this->application = Runnable::newClassInstance($className); |
| 194 | 194 | $this->application->setContext($this); |
| 195 | 195 | $this->application->setPath($this->path); |
@@ -162,8 +162,8 @@ |
||
| 162 | 162 | */ |
| 163 | 163 | protected function registerModuleManager() |
| 164 | 164 | { |
| 165 | - $this->manager = new Manager($this->getContext()); |
|
| 166 | - $this->manager->registerModule(); |
|
| 165 | + $this->manager = new Manager($this->getContext()); |
|
| 166 | + $this->manager->registerModule(); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -84,9 +84,9 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | public function getRoute(string $groupName): GroupRoutes |
| 86 | 86 | { |
| 87 | - $group = $groupName === 'default' ? '': '-'. $groupName; |
|
| 88 | - $routeConfig = $this->getConfig('route'.$group, ['group' => $group,]); |
|
| 89 | - $routes = new GroupRoutes($groupName); |
|
| 87 | + $group = $groupName === 'default' ? '' : '-'.$groupName; |
|
| 88 | + $routeConfig = $this->getConfig('route'.$group, ['group' => $group, ]); |
|
| 89 | + $routes = new GroupRoutes($groupName); |
|
| 90 | 90 | if (\is_array($routeConfig)) { |
| 91 | 91 | // debug()->debug('load route {group} from {module}',['group'=>$groupName, 'module' => $this->getFullName()]); |
| 92 | 92 | $prefix = $this->config->get('route.prefix', ''); |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | public function getFullName() |
| 131 | 131 | { |
| 132 | - return $this->name .':'. $this->version; |
|
| 132 | + return $this->name.':'.$this->version; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -148,8 +148,8 @@ |
||
| 148 | 148 | $this->module[$module->getFullName()] = $module; |
| 149 | 149 | $this->getContext()->getDebugger()->info('register module {name} at {path}', ['name'=>$module->getFullName(), 'path'=>$module->getPath()]); |
| 150 | 150 | } |
| 151 | - $this->buildLoadingOrder('alive', 'loadingOrder'); |
|
| 152 | - $this->buildLoadingOrder('reachable', 'routeLoadingOrder'); |
|
| 151 | + $this->buildLoadingOrder('alive', 'loadingOrder'); |
|
| 152 | + $this->buildLoadingOrder('reachable', 'routeLoadingOrder'); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | public function registerModule() |
| 141 | 141 | { |
| 142 | 142 | $scan = $this->getContext()->getConfig()->get('app.module.scan-path', []); |
| 143 | - $cache = $this->getContext()->getApplication()->getDataPath() .'/module-cache'; |
|
| 143 | + $cache = $this->getContext()->getApplication()->getDataPath().'/module-cache'; |
|
| 144 | 144 | FileSystem::makes($cache); |
| 145 | 145 | // 扫描加载 |
| 146 | 146 | foreach (Builder::scan($scan, $cache) as $module) { |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * @param string $name |
| 191 | 191 | * @return Module|null |
| 192 | 192 | */ |
| 193 | - public function find(string $name):?Module |
|
| 193 | + public function find(string $name): ?Module |
|
| 194 | 194 | { |
| 195 | 195 | $fullName = $this->finder->getFullName($name); |
| 196 | 196 | return $this->module[$fullName] ?? null; |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | public function loadFromModule(Manager $manager) { |
| 50 | 50 | $groups = $this->applicaton->getConfig()->get('app.active',['default']); |
| 51 | 51 | foreach ($groups as $group) { |
| 52 | - $manager->loadRoute($group, $this); |
|
| 52 | + $manager->loadRoute($group, $this); |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * @return void |
| 48 | 48 | */ |
| 49 | 49 | public function loadFromModule(Manager $manager) { |
| 50 | - $groups = $this->applicaton->getConfig()->get('app.active',['default']); |
|
| 50 | + $groups = $this->applicaton->getConfig()->get('app.active', ['default']); |
|
| 51 | 51 | foreach ($groups as $group) { |
| 52 | 52 | $manager->loadRoute($group, $this); |
| 53 | 53 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | public function addGroupRoute(string $group, GroupRoutes $route) { |
| 64 | 64 | if (\array_key_exists($group, $this->routes)) { |
| 65 | 65 | $this->routes[$group]->merge($route); |
| 66 | - }else{ |
|
| 66 | + } else { |
|
| 67 | 67 | $this->routes[$group] = $route; |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | public function addGroupRoute(string $group, GroupRoutes $route) { |
| 64 | 64 | if (\array_key_exists($group, $this->routes)) { |
| 65 | 65 | $this->routes[$group]->merge($route); |
| 66 | - }else{ |
|
| 66 | + } else{ |
|
| 67 | 67 | $this->routes[$group] = $route; |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -3,15 +3,15 @@ |
||
| 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 | |
| 10 | 10 | // 初始化系统加载器 |
| 11 | 11 | $loader = new Loader; |
| 12 | 12 | $loader->register(); |
| 13 | -$loader->addIncludePath(NEBULA_SYSTEM .'/src', 'nebula'); |
|
| 14 | -$loader->import(NEBULA_SYSTEM .'/src/functions.php'); |
|
| 13 | +$loader->addIncludePath(NEBULA_SYSTEM.'/src', 'nebula'); |
|
| 14 | +$loader->import(NEBULA_SYSTEM.'/src/functions.php'); |
|
| 15 | 15 | // 初始化请求 |
| 16 | 16 | $request = Request::buildFromServer(); |
| 17 | 17 | $request->apply(true); |