@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | { |
53 | 53 | foreach ($this->application->getModules() as $name => $module) { |
54 | 54 | if ($module->getStatus() === Module::REACHABLE) { |
55 | - call_user_func([$this->moduleLoader[$name],'toReachable']); |
|
55 | + call_user_func([$this->moduleLoader[$name], 'toReachable']); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function getDataSourceGroup(string $groupName):DataSource |
95 | 95 | { |
96 | - $group = $groupName === 'default' ? '': '-'. $groupName; |
|
96 | + $group = $groupName === 'default' ? '' : '-'.$groupName; |
|
97 | 97 | $dataSourceConfigPath = $this->application->getResource()->getConfigResourcePath('config/data-source'.$group); |
98 | 98 | $dataSource = new DataSource; |
99 | 99 | $observer = new DebugObserver($this->application->debug()); |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | |
162 | 162 | protected function registerModule() |
163 | 163 | { |
164 | - $extractPath = SUDA_DATA .'/extract-module'; |
|
164 | + $extractPath = SUDA_DATA.'/extract-module'; |
|
165 | 165 | FileSystem::make($extractPath); |
166 | 166 | foreach ($this->application->getModulePaths() as $path) { |
167 | 167 | $this->registerModuleFrom($path, $extractPath); |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | } |
188 | 188 | $config = $config ?? []; |
189 | 189 | $moduleNames = array_keys($modules->all()); |
190 | - $load = $config['load'] ?? $moduleNames; |
|
190 | + $load = $config['load'] ?? $moduleNames; |
|
191 | 191 | $this->loadModules($modules, $load); |
192 | 192 | $active = $config['active'] ?? $load; |
193 | 193 | $this->setModuleActive($modules, $active); |
@@ -14,10 +14,10 @@ |
||
14 | 14 | public function __construct(Throwable $exception) |
15 | 15 | { |
16 | 16 | parent::__construct('', []); |
17 | - $this->path = SUDA_RESOURCE. '/error.php'; |
|
17 | + $this->path = SUDA_RESOURCE.'/error.php'; |
|
18 | 18 | $type = get_class($exception); |
19 | 19 | $this->value = [ |
20 | - 'error_type' => $type , |
|
20 | + 'error_type' => $type, |
|
21 | 21 | 'error_sort_type' => strpos($type, '\\') === false ? $type : substr($type, strrpos($type, '\\') + 1), |
22 | 22 | 'error_code' => $exception->getCode(), |
23 | 23 | 'error_message' => $exception->getMessage(), |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | |
111 | 111 | protected function getStaticOutpath() |
112 | 112 | { |
113 | - $path = $this->config['assets-public'] ?? constant('SUDA_PUBLIC') . '/assets/' . $this->getStaticName(); |
|
113 | + $path = $this->config['assets-public'] ?? constant('SUDA_PUBLIC').'/assets/'.$this->getStaticName(); |
|
114 | 114 | FileSystem::make($path); |
115 | 115 | return $path; |
116 | 116 | } |
@@ -122,9 +122,9 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function getPath() |
124 | 124 | { |
125 | - $output = $this->config['output'] ?? constant('SUDA_DATA') . '/template'; |
|
125 | + $output = $this->config['output'] ?? constant('SUDA_DATA').'/template'; |
|
126 | 126 | FileSystem::make($output); |
127 | - return $output . '/' . $this->name . '-' . substr(md5_file($this->getSourcePath()), 10, 8) . '.php'; |
|
127 | + return $output.'/'.$this->name.'-'.substr(md5_file($this->getSourcePath()), 10, 8).'.php'; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | public function include(string $path) |
227 | 227 | { |
228 | 228 | $subfix = $this->config['subfix'] ?? ''; |
229 | - $included = new self(Resource::getPathByRelativePath($path . $subfix, dirname($this->source)), $this->config); |
|
229 | + $included = new self(Resource::getPathByRelativePath($path.$subfix, dirname($this->source)), $this->config); |
|
230 | 230 | $included->parent = $this; |
231 | 231 | echo $included->getRenderedString(); |
232 | 232 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | } else { |
250 | 250 | $prefix = '/assets'; |
251 | 251 | } |
252 | - return $prefix . '/' . $this->getStaticName(); |
|
252 | + return $prefix.'/'.$this->getStaticName(); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | protected function prepareStaticSource() |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | } |
289 | 289 | } |
290 | 290 | } catch (Exception $e) { |
291 | - echo '<div style="color:red">' . $e->getMessage() . '</div>'; |
|
291 | + echo '<div style="color:red">'.$e->getMessage().'</div>'; |
|
292 | 292 | return; |
293 | 293 | } |
294 | 294 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | public function getSourcePath(): ?string |
25 | 25 | { |
26 | 26 | $subfix = $this->config['subfix'] ?? '.tpl.html'; |
27 | - return $this->getResource($this->module)->getResourcePath($this->getTemplatePath() . '/' . $this->name . $subfix); |
|
27 | + return $this->getResource($this->module)->getResourcePath($this->getTemplatePath().'/'.$this->name.$subfix); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function getPath() |
36 | 36 | { |
37 | - $output = $this->config['output'] ?? $this->application->getDataPath() . '/template/' . $this->uriName; |
|
37 | + $output = $this->config['output'] ?? $this->application->getDataPath().'/template/'.$this->uriName; |
|
38 | 38 | FileSystem::make($output); |
39 | - return $output . '/' . $this->name . '.php'; |
|
39 | + return $output.'/'.$this->name.'.php'; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -56,18 +56,18 @@ discard block |
||
56 | 56 | |
57 | 57 | public function getRenderedString() |
58 | 58 | { |
59 | - $this->application->debug()->time('render ' . $this->name); |
|
59 | + $this->application->debug()->time('render '.$this->name); |
|
60 | 60 | $code = parent::getRenderedString(); |
61 | - $this->application->debug()->timeEnd('render ' . $this->name); |
|
61 | + $this->application->debug()->timeEnd('render '.$this->name); |
|
62 | 62 | return $code; |
63 | 63 | } |
64 | 64 | |
65 | 65 | protected function compile() |
66 | 66 | { |
67 | 67 | if ($this->isCompiled() === false) { |
68 | - $this->application->debug()->time('compile ' . $this->name); |
|
68 | + $this->application->debug()->time('compile '.$this->name); |
|
69 | 69 | $result = parent::compile(); |
70 | - $this->application->debug()->timeEnd('compile ' . $this->name); |
|
70 | + $this->application->debug()->timeEnd('compile '.$this->name); |
|
71 | 71 | return $result; |
72 | 72 | } |
73 | 73 | return true; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | } |
106 | 106 | return $this->application->getUrl($this->request, $name, $values ?? [], true, $this->module, $this->group); |
107 | 107 | } elseif (is_string($defaultName)) { |
108 | - $parameter = is_array($name)?array_merge($query, $name):$query; |
|
108 | + $parameter = is_array($name) ?array_merge($query, $name) : $query; |
|
109 | 109 | return $this->application->getUrl( |
110 | 110 | $this->request, |
111 | 111 | $defaultName, |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $this->group |
116 | 116 | ); |
117 | 117 | } |
118 | - return '#' . $defaultName; |
|
118 | + return '#'.$defaultName; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 |
@@ -98,7 +98,7 @@ |
||
98 | 98 | return ob_get_clean(); |
99 | 99 | } |
100 | 100 | throw new NoTemplateFoundException( |
101 | - 'missing dest at ' . $this->getPath(), |
|
101 | + 'missing dest at '.$this->getPath(), |
|
102 | 102 | E_USER_ERROR, |
103 | 103 | $this->getPath(), |
104 | 104 | 1 |
@@ -37,7 +37,7 @@ |
||
37 | 37 | */ |
38 | 38 | public function register() |
39 | 39 | { |
40 | - set_exception_handler([$this,'uncaughtException']); |
|
40 | + set_exception_handler([$this, 'uncaughtException']); |
|
41 | 41 | return $this; |
42 | 42 | } |
43 | 43 |
@@ -40,16 +40,16 @@ discard block |
||
40 | 40 | $this->debug->info('==============================='); |
41 | 41 | $this->debug->time('loading application'); |
42 | 42 | $appLoader->load(); |
43 | - $this->event->exec('application:load-config', [ $this->config ,$this]); |
|
43 | + $this->event->exec('application:load-config', [$this->config, $this]); |
|
44 | 44 | $this->debug->timeEnd('loading application'); |
45 | 45 | $this->debug->time('loading data-source'); |
46 | 46 | $appLoader->loadDataSource(); |
47 | 47 | $this->debug->timeEnd('loading data-source'); |
48 | 48 | Database::loadApplication($this); |
49 | - $this->event->exec('application:load-environment', [ $this->config ,$this]); |
|
49 | + $this->event->exec('application:load-environment', [$this->config, $this]); |
|
50 | 50 | $this->debug->time('loading route'); |
51 | 51 | $appLoader->loadRoute(); |
52 | - $this->event->exec('application:load-route', [$this->route , $this]); |
|
52 | + $this->event->exec('application:load-route', [$this->route, $this]); |
|
53 | 53 | $this->debug->timeEnd('loading route'); |
54 | 54 | $this->debug->info('-------------------------------'); |
55 | 55 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | if (!$response->isSend()) { |
107 | 107 | $response->end(); |
108 | 108 | } |
109 | - $this->debug->info('responded with code '. $response->getStatus()); |
|
109 | + $this->debug->info('responded with code '.$response->getStatus()); |
|
110 | 110 | $this->debug->timeEnd('sending response'); |
111 | 111 | } catch (Throwable $e) { |
112 | 112 | $this->debug->uncaughtException($e); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | protected function createResponse(?MatchResult $result, Request $request, Response $response) |
174 | 174 | { |
175 | 175 | if (SUDA_DEBUG) { |
176 | - $response->setHeader('x-route', $result === null?'default':$result->getName()); |
|
176 | + $response->setHeader('x-route', $result === null ? 'default' : $result->getName()); |
|
177 | 177 | } |
178 | 178 | if ($result === null) { |
179 | 179 | $content = $this->defaultResponse($this, $request, $response); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | // 添加 * ? 匹配 |
37 | 37 | $url = str_replace(['\*', '\?'], ['[^/]*?', '[^/]'], $url); |
38 | 38 | // 编译页面参数 |
39 | - $url = preg_replace_callback('/\{(\w+)(?:\:([^}]+?))?\}/', function ($match) use (&$parameters) { |
|
39 | + $url = preg_replace_callback('/\{(\w+)(?:\:([^}]+?))?\}/', function($match) use (&$parameters) { |
|
40 | 40 | $name = $match[1]; |
41 | 41 | $type = 'string'; |
42 | 42 | $extra = ''; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $url = static::parseIgnorableParameter($url, $matcher, $parameter, $mapper); |
71 | 71 | $url = static::replaceParameter($url, $matcher, $parameter, $mapper); |
72 | 72 | if (count($query) && $allowQuery) { |
73 | - return $url . '?' . http_build_query($query, 'v', '&', PHP_QUERY_RFC3986); |
|
73 | + return $url.'?'.http_build_query($query, 'v', '&', PHP_QUERY_RFC3986); |
|
74 | 74 | } |
75 | 75 | return $url; |
76 | 76 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | array $parameter, |
89 | 89 | array $mapper |
90 | 90 | ): string { |
91 | - return preg_replace_callback('/\[(.+?)\]/', function ($match) use ($matcher, $parameter, $mapper) { |
|
91 | + return preg_replace_callback('/\[(.+?)\]/', function($match) use ($matcher, $parameter, $mapper) { |
|
92 | 92 | if (preg_match('/\{(\w+).+?\}/', $match[1])) { |
93 | 93 | $count = 0; |
94 | 94 | $subUrl = static::replaceParameter($match[1], $matcher, $parameter, $mapper, true, $count); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | foreach ($parameter as $key => $value) { |
108 | 108 | if (is_numeric($key)) { |
109 | 109 | $mp = $matcher->getParameterByIndex($key); |
110 | - if ($mp !== null) { |
|
110 | + if ($mp !== null) { |
|
111 | 111 | unset($parameter[$key]); |
112 | 112 | $key = $mp->getIndexName(); |
113 | 113 | $parameter[$key] = $value; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | ) { |
144 | 144 | return preg_replace_callback( |
145 | 145 | '/\{(\w+).+?\}/', |
146 | - function ($match) use ($matcher, $parameter, $mapper, $ignore, &$count) { |
|
146 | + function($match) use ($matcher, $parameter, $mapper, $ignore, &$count) { |
|
147 | 147 | if (array_key_exists($match[1], $mapper)) { |
148 | 148 | $count++; |
149 | 149 | return $mapper[$match[1]]->packValue($parameter[$match[1]]); |
@@ -62,12 +62,12 @@ discard block |
||
62 | 62 | $methodStart = $splitLength ?: strpos($command, '::') ?: $dynmicsMethod; |
63 | 63 | $parameter = self::buildParameter($parameter); |
64 | 64 | if ($methodStart > 0) { |
65 | - $splitLength = $splitLength > 0 ? 1:2; |
|
65 | + $splitLength = $splitLength > 0 ? 1 : 2; |
|
66 | 66 | $methodName = substr($command, $methodStart + $splitLength); |
67 | 67 | $command = substr($command, 0, $methodStart); |
68 | 68 | list($className, $constructParameter) = self::splitParameter($command); |
69 | 69 | $constructParameter = self::buildParameter($constructParameter); |
70 | - $target = new MethodTarget($className, $dynmicsMethod? $constructParameter :null, $methodName, $parameter); |
|
70 | + $target = new MethodTarget($className, $dynmicsMethod ? $constructParameter : null, $methodName, $parameter); |
|
71 | 71 | } else { |
72 | 72 | $target = new FunctionTarget(self::buildName($command), $parameter); |
73 | 73 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | if (preg_match('/^[\w\\\\\/.]+$/', $name) !== 1) { |
100 | 100 | throw new InvalidNameException(sprintf('invalid name: %s ', $name)); |
101 | 101 | } |
102 | - return str_replace(['.','/'], '\\', $name); |
|
102 | + return str_replace(['.', '/'], '\\', $name); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | private static function splitParameter(string $command):array |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $parameter = substr($command, $paramStart + 1, strlen($command) - $paramStart - 2); |
111 | 111 | $command = substr($command, 0, $paramStart); |
112 | 112 | } |
113 | - return [$command,$parameter]; |
|
113 | + return [$command, $parameter]; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | private static function buildParameter(?string $parameter) |