@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | foreach ($files as $file) { |
138 | 138 | if (pathinfo($file, PATHINFO_EXTENSION) == 'php') { |
139 | - include $config['auto_path'] . $file; |
|
139 | + include $config['auto_path'].$file; |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
148 | - $file = Container::get('env')->get('app_path') . 'command.php'; |
|
148 | + $file = Container::get('env')->get('app_path').'command.php'; |
|
149 | 149 | |
150 | 150 | if (is_file($file)) { |
151 | 151 | $appCommands = include $file; |
@@ -513,10 +513,10 @@ discard block |
||
513 | 513 | public function findNamespace($namespace) |
514 | 514 | { |
515 | 515 | $allNamespaces = $this->getNamespaces(); |
516 | - $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { |
|
517 | - return preg_quote($matches[1]) . '[^:]*'; |
|
516 | + $expr = preg_replace_callback('{([^:]+|)}', function($matches) { |
|
517 | + return preg_quote($matches[1]).'[^:]*'; |
|
518 | 518 | }, $namespace); |
519 | - $namespaces = preg_grep('{^' . $expr . '}', $allNamespaces); |
|
519 | + $namespaces = preg_grep('{^'.$expr.'}', $allNamespaces); |
|
520 | 520 | |
521 | 521 | if (empty($namespaces)) { |
522 | 522 | $message = sprintf('There are no commands defined in the "%s" namespace.', $namespace); |
@@ -553,13 +553,13 @@ discard block |
||
553 | 553 | { |
554 | 554 | $allCommands = array_keys($this->commands); |
555 | 555 | |
556 | - $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { |
|
557 | - return preg_quote($matches[1]) . '[^:]*'; |
|
556 | + $expr = preg_replace_callback('{([^:]+|)}', function($matches) { |
|
557 | + return preg_quote($matches[1]).'[^:]*'; |
|
558 | 558 | }, $name); |
559 | 559 | |
560 | - $commands = preg_grep('{^' . $expr . '}', $allCommands); |
|
560 | + $commands = preg_grep('{^'.$expr.'}', $allCommands); |
|
561 | 561 | |
562 | - if (empty($commands) || count(preg_grep('{^' . $expr . '$}', $commands)) < 1) { |
|
562 | + if (empty($commands) || count(preg_grep('{^'.$expr.'$}', $commands)) < 1) { |
|
563 | 563 | if (false !== $pos = strrpos($name, ':')) { |
564 | 564 | $this->findNamespace(substr($name, 0, $pos)); |
565 | 565 | } |
@@ -779,7 +779,7 @@ discard block |
||
779 | 779 | } |
780 | 780 | } |
781 | 781 | |
782 | - $alternatives = array_filter($alternatives, function ($lev) use ($threshold) { |
|
782 | + $alternatives = array_filter($alternatives, function($lev) use ($threshold) { |
|
783 | 783 | return $lev < 2 * $threshold; |
784 | 784 | }); |
785 | 785 | asort($alternatives); |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | |
811 | 811 | foreach ($parts as $part) { |
812 | 812 | if (count($namespaces)) { |
813 | - $namespaces[] = end($namespaces) . ':' . $part; |
|
813 | + $namespaces[] = end($namespaces).':'.$part; |
|
814 | 814 | } else { |
815 | 815 | $namespaces[] = $part; |
816 | 816 | } |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | public function run(array $build = [], $namespace = 'app', $suffix = false) |
43 | 43 | { |
44 | 44 | // 锁定 |
45 | - $lockfile = $this->basePath . 'build.lock'; |
|
45 | + $lockfile = $this->basePath.'build.lock'; |
|
46 | 46 | |
47 | 47 | if (is_writable($lockfile)) { |
48 | 48 | return; |
49 | 49 | } elseif (!touch($lockfile)) { |
50 | - throw new Exception('应用目录[' . $this->basePath . ']不可写,目录无法自动生成!<BR>请手动生成项目目录~', 10006); |
|
50 | + throw new Exception('应用目录['.$this->basePath.']不可写,目录无法自动生成!<BR>请手动生成项目目录~', 10006); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | foreach ($build as $module => $list) { |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | protected function buildDir($list) |
77 | 77 | { |
78 | 78 | foreach ($list as $dir) { |
79 | - $this->checkDirBuild($this->basePath . $dir); |
|
79 | + $this->checkDirBuild($this->basePath.$dir); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | protected function buildFile($list) |
90 | 90 | { |
91 | 91 | foreach ($list as $file) { |
92 | - if (!is_dir($this->basePath . dirname($file))) { |
|
92 | + if (!is_dir($this->basePath.dirname($file))) { |
|
93 | 93 | // 创建目录 |
94 | - mkdir($this->basePath . dirname($file), 0755, true); |
|
94 | + mkdir($this->basePath.dirname($file), 0755, true); |
|
95 | 95 | } |
96 | 96 | |
97 | - if (!is_file($this->basePath . $file)) { |
|
98 | - file_put_contents($this->basePath . $file, 'php' == pathinfo($file, PATHINFO_EXTENSION) ? "<?php\n" : ''); |
|
97 | + if (!is_file($this->basePath.$file)) { |
|
98 | + file_put_contents($this->basePath.$file, 'php' == pathinfo($file, PATHINFO_EXTENSION) ? "<?php\n" : ''); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | { |
114 | 114 | $module = $module ? $module : ''; |
115 | 115 | |
116 | - if (!is_dir($this->basePath . $module)) { |
|
116 | + if (!is_dir($this->basePath.$module)) { |
|
117 | 117 | // 创建模块目录 |
118 | - mkdir($this->basePath . $module); |
|
118 | + mkdir($this->basePath.$module); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | if (basename($this->app->getRuntimePath()) != $module) { |
@@ -135,26 +135,26 @@ discard block |
||
135 | 135 | |
136 | 136 | // 创建子目录和文件 |
137 | 137 | foreach ($list as $path => $file) { |
138 | - $modulePath = $this->basePath . $module . DIRECTORY_SEPARATOR; |
|
138 | + $modulePath = $this->basePath.$module.DIRECTORY_SEPARATOR; |
|
139 | 139 | if ('__dir__' == $path) { |
140 | 140 | // 生成子目录 |
141 | 141 | foreach ($file as $dir) { |
142 | - $this->checkDirBuild($modulePath . $dir); |
|
142 | + $this->checkDirBuild($modulePath.$dir); |
|
143 | 143 | } |
144 | 144 | } elseif ('__file__' == $path) { |
145 | 145 | // 生成(空白)文件 |
146 | 146 | foreach ($file as $name) { |
147 | - if (!is_file($modulePath . $name)) { |
|
148 | - file_put_contents($modulePath . $name, 'php' == pathinfo($name, PATHINFO_EXTENSION) ? "<?php\n" : ''); |
|
147 | + if (!is_file($modulePath.$name)) { |
|
148 | + file_put_contents($modulePath.$name, 'php' == pathinfo($name, PATHINFO_EXTENSION) ? "<?php\n" : ''); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | } else { |
152 | 152 | // 生成相关MVC文件 |
153 | 153 | foreach ($file as $val) { |
154 | 154 | $val = trim($val); |
155 | - $filename = $modulePath . $path . DIRECTORY_SEPARATOR . $val . ($suffix ? ucfirst($path) : '') . '.php'; |
|
156 | - $space = $namespace . '\\' . ($module ? $module . '\\' : '') . $path; |
|
157 | - $class = $val . ($suffix ? ucfirst($path) : ''); |
|
155 | + $filename = $modulePath.$path.DIRECTORY_SEPARATOR.$val.($suffix ? ucfirst($path) : '').'.php'; |
|
156 | + $space = $namespace.'\\'.($module ? $module.'\\' : '').$path; |
|
157 | + $class = $val.($suffix ? ucfirst($path) : ''); |
|
158 | 158 | switch ($path) { |
159 | 159 | case 'controller': // 控制器 |
160 | 160 | $content = "<?php\nnamespace {$space};\n\nclass {$class}\n{\n\n}"; |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $content = "<?php\nnamespace {$space};\n\nuse think\Model;\n\nclass {$class} extends Model\n{\n\n}"; |
164 | 164 | break; |
165 | 165 | case 'view': // 视图 |
166 | - $filename = $modulePath . $path . DIRECTORY_SEPARATOR . $val . '.html'; |
|
166 | + $filename = $modulePath.$path.DIRECTORY_SEPARATOR.$val.'.html'; |
|
167 | 167 | $this->checkDirBuild(dirname($filename)); |
168 | 168 | $content = ''; |
169 | 169 | break; |
@@ -190,14 +190,14 @@ discard block |
||
190 | 190 | public function buildRoute($suffix = false, $layer = '') |
191 | 191 | { |
192 | 192 | $namespace = $this->app->getNameSpace(); |
193 | - $content = '<?php ' . PHP_EOL . '//根据 Annotation 自动生成的路由规则'; |
|
193 | + $content = '<?php '.PHP_EOL.'//根据 Annotation 自动生成的路由规则'; |
|
194 | 194 | |
195 | 195 | if (!$layer) { |
196 | 196 | $layer = $this->app->config('app.url_controller_layer'); |
197 | 197 | } |
198 | 198 | |
199 | 199 | if ($this->app->config('app.app_multi_module')) { |
200 | - $modules = glob($this->basePath . '*', GLOB_ONLYDIR); |
|
200 | + $modules = glob($this->basePath.'*', GLOB_ONLYDIR); |
|
201 | 201 | |
202 | 202 | foreach ($modules as $module) { |
203 | 203 | $module = basename($module); |
@@ -206,15 +206,15 @@ discard block |
||
206 | 206 | continue; |
207 | 207 | } |
208 | 208 | |
209 | - $path = $this->basePath . $module . DIRECTORY_SEPARATOR . $layer . DIRECTORY_SEPARATOR; |
|
209 | + $path = $this->basePath.$module.DIRECTORY_SEPARATOR.$layer.DIRECTORY_SEPARATOR; |
|
210 | 210 | $content .= $this->buildDirRoute($path, $namespace, $module, $suffix, $layer); |
211 | 211 | } |
212 | 212 | } else { |
213 | - $path = $this->basePath . $layer . DIRECTORY_SEPARATOR; |
|
213 | + $path = $this->basePath.$layer.DIRECTORY_SEPARATOR; |
|
214 | 214 | $content .= $this->buildDirRoute($path, $namespace, '', $suffix, $layer); |
215 | 215 | } |
216 | 216 | |
217 | - $filename = $this->app->getRuntimePath() . 'build_route.php'; |
|
217 | + $filename = $this->app->getRuntimePath().'build_route.php'; |
|
218 | 218 | file_put_contents($filename, $content); |
219 | 219 | |
220 | 220 | return $filename; |
@@ -233,17 +233,17 @@ discard block |
||
233 | 233 | protected function buildDirRoute($path, $namespace, $module, $suffix, $layer) |
234 | 234 | { |
235 | 235 | $content = ''; |
236 | - $controllers = glob($path . '*.php'); |
|
236 | + $controllers = glob($path.'*.php'); |
|
237 | 237 | |
238 | 238 | foreach ($controllers as $controller) { |
239 | 239 | $controller = basename($controller, '.php'); |
240 | 240 | |
241 | - $class = new \ReflectionClass($namespace . '\\' . ($module ? $module . '\\' : '') . $layer . '\\' . $controller); |
|
241 | + $class = new \ReflectionClass($namespace.'\\'.($module ? $module.'\\' : '').$layer.'\\'.$controller); |
|
242 | 242 | |
243 | 243 | if (strpos($layer, '\\')) { |
244 | 244 | // 多级控制器 |
245 | 245 | $level = str_replace(DIRECTORY_SEPARATOR, '.', substr($layer, 11)); |
246 | - $controller = $level . '.' . $controller; |
|
246 | + $controller = $level.'.'.$controller; |
|
247 | 247 | $length = strlen(strstr($layer, '\\', true)); |
248 | 248 | } else { |
249 | 249 | $length = strlen($layer); |
@@ -256,10 +256,10 @@ discard block |
||
256 | 256 | $content .= $this->getControllerRoute($class, $module, $controller); |
257 | 257 | } |
258 | 258 | |
259 | - $subDir = glob($path . '*', GLOB_ONLYDIR); |
|
259 | + $subDir = glob($path.'*', GLOB_ONLYDIR); |
|
260 | 260 | |
261 | 261 | foreach ($subDir as $dir) { |
262 | - $content .= $this->buildDirRoute($dir . DIRECTORY_SEPARATOR, $namespace, $module, $suffix, $layer . '\\' . basename($dir)); |
|
262 | + $content .= $this->buildDirRoute($dir.DIRECTORY_SEPARATOR, $namespace, $module, $suffix, $layer.'\\'.basename($dir)); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | return $content; |
@@ -280,14 +280,14 @@ discard block |
||
280 | 280 | |
281 | 281 | if (false !== strpos($comment, '@route(')) { |
282 | 282 | $comment = $this->parseRouteComment($comment); |
283 | - $route = ($module ? $module . '/' : '') . $controller; |
|
284 | - $comment = preg_replace('/route\(\s?([\'\"][\-\_\/\:\<\>\?\$\[\]\w]+[\'\"])\s?\)/is', 'Route::resource(\1,\'' . $route . '\')', $comment); |
|
285 | - $content .= PHP_EOL . $comment; |
|
283 | + $route = ($module ? $module.'/' : '').$controller; |
|
284 | + $comment = preg_replace('/route\(\s?([\'\"][\-\_\/\:\<\>\?\$\[\]\w]+[\'\"])\s?\)/is', 'Route::resource(\1,\''.$route.'\')', $comment); |
|
285 | + $content .= PHP_EOL.$comment; |
|
286 | 286 | } elseif (false !== strpos($comment, '@alias(')) { |
287 | 287 | $comment = $this->parseRouteComment($comment, '@alias('); |
288 | - $route = ($module ? $module . '/' : '') . $controller; |
|
289 | - $comment = preg_replace('/alias\(\s?([\'\"][\-\_\/\w]+[\'\"])\s?\)/is', 'Route::alias(\1,\'' . $route . '\')', $comment); |
|
290 | - $content .= PHP_EOL . $comment; |
|
288 | + $route = ($module ? $module.'/' : '').$controller; |
|
289 | + $comment = preg_replace('/alias\(\s?([\'\"][\-\_\/\w]+[\'\"])\s?\)/is', 'Route::alias(\1,\''.$route.'\')', $comment); |
|
290 | + $content .= PHP_EOL.$comment; |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | $methods = $class->getMethods(\ReflectionMethod::IS_PUBLIC); |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | foreach ($methods as $method) { |
296 | 296 | $comment = $this->getMethodRouteComment($module, $controller, $method); |
297 | 297 | if ($comment) { |
298 | - $content .= PHP_EOL . $comment; |
|
298 | + $content .= PHP_EOL.$comment; |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 | |
@@ -313,18 +313,18 @@ discard block |
||
313 | 313 | { |
314 | 314 | $comment = substr($comment, 3, -2); |
315 | 315 | $comment = explode(PHP_EOL, substr(strstr(trim($comment), $tag), 1)); |
316 | - $comment = array_map(function ($item) {return trim(trim($item), ' \t*');}, $comment); |
|
316 | + $comment = array_map(function($item) {return trim(trim($item), ' \t*'); }, $comment); |
|
317 | 317 | |
318 | 318 | if (count($comment) > 1) { |
319 | 319 | $key = array_search('', $comment); |
320 | 320 | $comment = array_slice($comment, 0, false === $key ? 1 : $key); |
321 | 321 | } |
322 | 322 | |
323 | - $comment = implode(PHP_EOL . "\t", $comment) . ';'; |
|
323 | + $comment = implode(PHP_EOL."\t", $comment).';'; |
|
324 | 324 | |
325 | 325 | if (strpos($comment, '{')) { |
326 | - $comment = preg_replace_callback('/\{\s?.*?\s?\}/s', function ($matches) { |
|
327 | - return false !== strpos($matches[0], '"') ? '[' . substr(var_export(json_decode($matches[0], true), true), 7, -1) . ']' : $matches[0]; |
|
326 | + $comment = preg_replace_callback('/\{\s?.*?\s?\}/s', function($matches) { |
|
327 | + return false !== strpos($matches[0], '"') ? '['.substr(var_export(json_decode($matches[0], true), true), 7, -1).']' : $matches[0]; |
|
328 | 328 | }, $comment); |
329 | 329 | } |
330 | 330 | return $comment; |
@@ -350,9 +350,9 @@ discard block |
||
350 | 350 | $action = substr($action, 0, -strlen($suffix)); |
351 | 351 | } |
352 | 352 | |
353 | - $route = ($module ? $module . '/' : '') . $controller . '/' . $action; |
|
354 | - $comment = preg_replace('/route\s?\(\s?([\'\"][\-\_\/\:\<\>\?\$\[\]\w]+[\'\"])\s?\,?\s?[\'\"]?(\w+?)[\'\"]?\s?\)/is', 'Route::\2(\1,\'' . $route . '\')', $comment); |
|
355 | - $comment = preg_replace('/route\s?\(\s?([\'\"][\-\_\/\:\<\>\?\$\[\]\w]+[\'\"])\s?\)/is', 'Route::rule(\1,\'' . $route . '\')', $comment); |
|
353 | + $route = ($module ? $module.'/' : '').$controller.'/'.$action; |
|
354 | + $comment = preg_replace('/route\s?\(\s?([\'\"][\-\_\/\:\<\>\?\$\[\]\w]+[\'\"])\s?\,?\s?[\'\"]?(\w+?)[\'\"]?\s?\)/is', 'Route::\2(\1,\''.$route.'\')', $comment); |
|
355 | + $comment = preg_replace('/route\s?\(\s?([\'\"][\-\_\/\:\<\>\?\$\[\]\w]+[\'\"])\s?\)/is', 'Route::rule(\1,\''.$route.'\')', $comment); |
|
356 | 356 | |
357 | 357 | return $comment; |
358 | 358 | } |
@@ -368,10 +368,10 @@ discard block |
||
368 | 368 | */ |
369 | 369 | protected function buildHello($module, $namespace, $suffix = false) |
370 | 370 | { |
371 | - $filename = $this->basePath . ($module ? $module . DIRECTORY_SEPARATOR : '') . 'controller' . DIRECTORY_SEPARATOR . 'Index' . ($suffix ? 'Controller' : '') . '.php'; |
|
371 | + $filename = $this->basePath.($module ? $module.DIRECTORY_SEPARATOR : '').'controller'.DIRECTORY_SEPARATOR.'Index'.($suffix ? 'Controller' : '').'.php'; |
|
372 | 372 | if (!is_file($filename)) { |
373 | - $content = file_get_contents($this->app->getThinkPath() . 'tpl' . DIRECTORY_SEPARATOR . 'default_index.tpl'); |
|
374 | - $content = str_replace(['{$app}', '{$module}', '{layer}', '{$suffix}'], [$namespace, $module ? $module . '\\' : '', 'controller', $suffix ? 'Controller' : ''], $content); |
|
373 | + $content = file_get_contents($this->app->getThinkPath().'tpl'.DIRECTORY_SEPARATOR.'default_index.tpl'); |
|
374 | + $content = str_replace(['{$app}', '{$module}', '{layer}', '{$suffix}'], [$namespace, $module ? $module.'\\' : '', 'controller', $suffix ? 'Controller' : ''], $content); |
|
375 | 375 | $this->checkDirBuild(dirname($filename)); |
376 | 376 | |
377 | 377 | file_put_contents($filename, $content); |
@@ -386,14 +386,14 @@ discard block |
||
386 | 386 | */ |
387 | 387 | protected function buildCommon($module) |
388 | 388 | { |
389 | - $filename = $this->app->getConfigPath() . ($module ? $module . DIRECTORY_SEPARATOR : '') . 'app.php'; |
|
389 | + $filename = $this->app->getConfigPath().($module ? $module.DIRECTORY_SEPARATOR : '').'app.php'; |
|
390 | 390 | $this->checkDirBuild(dirname($filename)); |
391 | 391 | |
392 | 392 | if (!is_file($filename)) { |
393 | 393 | file_put_contents($filename, "<?php\n//配置文件\nreturn [\n\n];"); |
394 | 394 | } |
395 | 395 | |
396 | - $filename = $this->basePath . ($module ? $module . DIRECTORY_SEPARATOR : '') . 'common.php'; |
|
396 | + $filename = $this->basePath.($module ? $module.DIRECTORY_SEPARATOR : '').'common.php'; |
|
397 | 397 | |
398 | 398 | if (!is_file($filename)) { |
399 | 399 | file_put_contents($filename, "<?php\n"); |
@@ -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 | |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | $files = scandir($this->routePath); |
552 | 552 | foreach ($files as $file) { |
553 | 553 | if (strpos($file, '.php')) { |
554 | - $filename = $this->routePath . $file; |
|
554 | + $filename = $this->routePath.$file; |
|
555 | 555 | // 导入路由配置 |
556 | 556 | $rules = include $filename; |
557 | 557 | if (is_array($rules)) { |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | $this->build->buildRoute($suffix); |
568 | 568 | } |
569 | 569 | |
570 | - $filename = $this->runtimePath . 'build_route.php'; |
|
570 | + $filename = $this->runtimePath.'build_route.php'; |
|
571 | 571 | |
572 | 572 | if (is_file($filename)) { |
573 | 573 | include $filename; |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | */ |
669 | 669 | public function create($name, $layer, $appendSuffix = false, $common = 'common') |
670 | 670 | { |
671 | - $guid = $name . $layer; |
|
671 | + $guid = $name.$layer; |
|
672 | 672 | |
673 | 673 | if ($this->__isset($guid)) { |
674 | 674 | return $this->__get($guid); |
@@ -679,11 +679,11 @@ discard block |
||
679 | 679 | if (class_exists($class)) { |
680 | 680 | $object = $this->__get($class); |
681 | 681 | } else { |
682 | - $class = str_replace('\\' . $module . '\\', '\\' . $common . '\\', $class); |
|
682 | + $class = str_replace('\\'.$module.'\\', '\\'.$common.'\\', $class); |
|
683 | 683 | if (class_exists($class)) { |
684 | 684 | $object = $this->__get($class); |
685 | 685 | } else { |
686 | - throw new ClassNotFoundException('class not exists:' . $class, $class); |
|
686 | + throw new ClassNotFoundException('class not exists:'.$class, $class); |
|
687 | 687 | } |
688 | 688 | } |
689 | 689 | |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | return $this->make($emptyClass, true); |
728 | 728 | } |
729 | 729 | |
730 | - throw new ClassNotFoundException('class not exists:' . $class, $class); |
|
730 | + throw new ClassNotFoundException('class not exists:'.$class, $class); |
|
731 | 731 | } |
732 | 732 | |
733 | 733 | /** |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | } |
789 | 789 | } |
790 | 790 | |
791 | - return $this->invokeMethod([$class, $action . $this->config('action_suffix')], $vars); |
|
791 | + return $this->invokeMethod([$class, $action.$this->config('action_suffix')], $vars); |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | /** |
@@ -804,10 +804,10 @@ discard block |
||
804 | 804 | { |
805 | 805 | $name = str_replace(['/', '.'], '\\', $name); |
806 | 806 | $array = explode('\\', $name); |
807 | - $class = Loader::parseName(array_pop($array), 1) . ($this->suffix || $appendSuffix ? ucfirst($layer) : ''); |
|
808 | - $path = $array ? implode('\\', $array) . '\\' : ''; |
|
807 | + $class = Loader::parseName(array_pop($array), 1).($this->suffix || $appendSuffix ? ucfirst($layer) : ''); |
|
808 | + $path = $array ? implode('\\', $array).'\\' : ''; |
|
809 | 809 | |
810 | - return $this->namespace . '\\' . ($module ? $module . '\\' : '') . $layer . '\\' . $path . $class; |
|
810 | + return $this->namespace.'\\'.($module ? $module.'\\' : '').$layer.'\\'.$path.$class; |
|
811 | 811 | } |
812 | 812 | |
813 | 813 | /** |
@@ -870,7 +870,7 @@ discard block |
||
870 | 870 | public function getAppPath() |
871 | 871 | { |
872 | 872 | if (is_null($this->appPath)) { |
873 | - $this->appPath = Loader::getRootPath() . 'application' . DIRECTORY_SEPARATOR; |
|
873 | + $this->appPath = Loader::getRootPath().'application'.DIRECTORY_SEPARATOR; |
|
874 | 874 | } |
875 | 875 | |
876 | 876 | return $this->appPath; |
@@ -120,7 +120,7 @@ |
||
120 | 120 | if (is_string($msg) && !empty($context)) { |
121 | 121 | $replace = []; |
122 | 122 | foreach ($context as $key => $val) { |
123 | - $replace['{' . $key . '}'] = $val; |
|
123 | + $replace['{'.$key.'}'] = $val; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | $msg = strtr($msg, $replace); |
@@ -188,11 +188,11 @@ discard block |
||
188 | 188 | |
189 | 189 | if (!empty($config['type'])) { |
190 | 190 | // 读取session驱动 |
191 | - $class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\session\\driver\\' . ucwords($config['type']); |
|
191 | + $class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\session\\driver\\'.ucwords($config['type']); |
|
192 | 192 | |
193 | 193 | // 检查驱动类 |
194 | 194 | if (!class_exists($class) || !session_set_save_handler(new $class($config))) { |
195 | - throw new ClassNotFoundException('error session handler:' . $class, $class); |
|
195 | + throw new ClassNotFoundException('error session handler:'.$class, $class); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | |
302 | 302 | if (!empty($config['type']) && isset($config['use_lock']) && $config['use_lock']) { |
303 | 303 | // 读取session驱动 |
304 | - $class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\session\\driver\\' . ucwords($config['type']); |
|
304 | + $class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\session\\driver\\'.ucwords($config['type']); |
|
305 | 305 | |
306 | 306 | // 检查驱动类及类中是否存在 lock 和 unlock 函数 |
307 | 307 | if (class_exists($class) && method_exists($class, 'lock') && method_exists($class, 'unlock')) { |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | |
66 | 66 | $path = realpath(dirname($scriptName)); |
67 | 67 | |
68 | - if (!is_file($path . DIRECTORY_SEPARATOR . 'think')) { |
|
68 | + if (!is_file($path.DIRECTORY_SEPARATOR.'think')) { |
|
69 | 69 | $path = dirname($path); |
70 | 70 | } |
71 | 71 | |
72 | - return $path . DIRECTORY_SEPARATOR; |
|
72 | + return $path.DIRECTORY_SEPARATOR; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | // 注册自动加载机制 |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | |
81 | 81 | $rootPath = self::getRootPath(); |
82 | 82 | |
83 | - self::$composerPath = $rootPath . 'vendor' . DIRECTORY_SEPARATOR . 'composer' . DIRECTORY_SEPARATOR; |
|
83 | + self::$composerPath = $rootPath.'vendor'.DIRECTORY_SEPARATOR.'composer'.DIRECTORY_SEPARATOR; |
|
84 | 84 | |
85 | 85 | // Composer自动加载支持 |
86 | 86 | if (is_dir(self::$composerPath)) { |
87 | - if (is_file(self::$composerPath . 'autoload_static.php')) { |
|
88 | - require self::$composerPath . 'autoload_static.php'; |
|
87 | + if (is_file(self::$composerPath.'autoload_static.php')) { |
|
88 | + require self::$composerPath.'autoload_static.php'; |
|
89 | 89 | |
90 | 90 | $declaredClass = get_declared_classes(); |
91 | 91 | $composerClass = array_pop($declaredClass); |
@@ -103,16 +103,16 @@ discard block |
||
103 | 103 | // 注册命名空间定义 |
104 | 104 | self::addNamespace([ |
105 | 105 | 'think' => __DIR__, |
106 | - 'traits' => dirname(__DIR__) . DIRECTORY_SEPARATOR . 'traits', |
|
106 | + 'traits' => dirname(__DIR__).DIRECTORY_SEPARATOR.'traits', |
|
107 | 107 | ]); |
108 | 108 | |
109 | 109 | // 加载类库映射文件 |
110 | - if (is_file($rootPath . 'runtime' . DIRECTORY_SEPARATOR . 'classmap.php')) { |
|
111 | - self::addClassMap(__include_file($rootPath . 'runtime' . DIRECTORY_SEPARATOR . 'classmap.php')); |
|
110 | + if (is_file($rootPath.'runtime'.DIRECTORY_SEPARATOR.'classmap.php')) { |
|
111 | + self::addClassMap(__include_file($rootPath.'runtime'.DIRECTORY_SEPARATOR.'classmap.php')); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | // 自动加载extend目录 |
115 | - self::addAutoLoadDir($rootPath . 'extend'); |
|
115 | + self::addAutoLoadDir($rootPath.'extend'); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | // 自动加载 |
@@ -148,14 +148,14 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | // 查找 PSR-4 |
151 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . '.php'; |
|
151 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).'.php'; |
|
152 | 152 | |
153 | 153 | $first = $class[0]; |
154 | 154 | if (isset(self::$prefixLengthsPsr4[$first])) { |
155 | 155 | foreach (self::$prefixLengthsPsr4[$first] as $prefix => $length) { |
156 | 156 | if (0 === strpos($class, $prefix)) { |
157 | 157 | foreach (self::$prefixDirsPsr4[$prefix] as $dir) { |
158 | - if (is_file($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { |
|
158 | + if (is_file($file = $dir.DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $length))) { |
|
159 | 159 | return $file; |
160 | 160 | } |
161 | 161 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | // 查找 PSR-4 fallback dirs |
167 | 167 | foreach (self::$fallbackDirsPsr4 as $dir) { |
168 | - if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
168 | + if (is_file($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) { |
|
169 | 169 | return $file; |
170 | 170 | } |
171 | 171 | } |
@@ -177,14 +177,14 @@ discard block |
||
177 | 177 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
178 | 178 | } else { |
179 | 179 | // PEAR-like class name |
180 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . '.php'; |
|
180 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).'.php'; |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | if (isset(self::$prefixesPsr0[$first])) { |
184 | 184 | foreach (self::$prefixesPsr0[$first] as $prefix => $dirs) { |
185 | 185 | if (0 === strpos($class, $prefix)) { |
186 | 186 | foreach ($dirs as $dir) { |
187 | - if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
187 | + if (is_file($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
188 | 188 | return $file; |
189 | 189 | } |
190 | 190 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | |
195 | 195 | // 查找 PSR-0 fallback dirs |
196 | 196 | foreach (self::$fallbackDirsPsr0 as $dir) { |
197 | - if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
197 | + if (is_file($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
198 | 198 | return $file; |
199 | 199 | } |
200 | 200 | } |
@@ -217,10 +217,10 @@ discard block |
||
217 | 217 | { |
218 | 218 | if (is_array($namespace)) { |
219 | 219 | foreach ($namespace as $prefix => $paths) { |
220 | - self::addPsr4($prefix . '\\', rtrim($paths, DIRECTORY_SEPARATOR), true); |
|
220 | + self::addPsr4($prefix.'\\', rtrim($paths, DIRECTORY_SEPARATOR), true); |
|
221 | 221 | } |
222 | 222 | } else { |
223 | - self::addPsr4($namespace . '\\', rtrim($path, DIRECTORY_SEPARATOR), true); |
|
223 | + self::addPsr4($namespace.'\\', rtrim($path, DIRECTORY_SEPARATOR), true); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
@@ -322,29 +322,29 @@ discard block |
||
322 | 322 | // 注册composer自动加载 |
323 | 323 | public static function registerComposerLoader($composerPath) |
324 | 324 | { |
325 | - if (is_file($composerPath . 'autoload_namespaces.php')) { |
|
326 | - $map = require $composerPath . 'autoload_namespaces.php'; |
|
325 | + if (is_file($composerPath.'autoload_namespaces.php')) { |
|
326 | + $map = require $composerPath.'autoload_namespaces.php'; |
|
327 | 327 | foreach ($map as $namespace => $path) { |
328 | 328 | self::addPsr0($namespace, $path); |
329 | 329 | } |
330 | 330 | } |
331 | 331 | |
332 | - if (is_file($composerPath . 'autoload_psr4.php')) { |
|
333 | - $map = require $composerPath . 'autoload_psr4.php'; |
|
332 | + if (is_file($composerPath.'autoload_psr4.php')) { |
|
333 | + $map = require $composerPath.'autoload_psr4.php'; |
|
334 | 334 | foreach ($map as $namespace => $path) { |
335 | 335 | self::addPsr4($namespace, $path); |
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
339 | - if (is_file($composerPath . 'autoload_classmap.php')) { |
|
340 | - $classMap = require $composerPath . 'autoload_classmap.php'; |
|
339 | + if (is_file($composerPath.'autoload_classmap.php')) { |
|
340 | + $classMap = require $composerPath.'autoload_classmap.php'; |
|
341 | 341 | if ($classMap) { |
342 | 342 | self::addClassMap($classMap); |
343 | 343 | } |
344 | 344 | } |
345 | 345 | |
346 | - if (is_file($composerPath . 'autoload_files.php')) { |
|
347 | - self::$files = require $composerPath . 'autoload_files.php'; |
|
346 | + if (is_file($composerPath.'autoload_files.php')) { |
|
347 | + self::$files = require $composerPath.'autoload_files.php'; |
|
348 | 348 | } |
349 | 349 | } |
350 | 350 | |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | public static function parseName($name, $type = 0, $ucfirst = true) |
373 | 373 | { |
374 | 374 | if ($type) { |
375 | - $name = preg_replace_callback('/_([a-zA-Z])/', function ($match) { |
|
375 | + $name = preg_replace_callback('/_([a-zA-Z])/', function($match) { |
|
376 | 376 | return strtoupper($match[1]); |
377 | 377 | }, $name); |
378 | 378 | return $ucfirst ? ucfirst($name) : lcfirst($name); |
@@ -390,12 +390,12 @@ discard block |
||
390 | 390 | */ |
391 | 391 | public static function factory($name, $namespace = '', ...$args) |
392 | 392 | { |
393 | - $class = false !== strpos($name, '\\') ? $name : $namespace . ucwords($name); |
|
393 | + $class = false !== strpos($name, '\\') ? $name : $namespace.ucwords($name); |
|
394 | 394 | |
395 | 395 | if (class_exists($class)) { |
396 | 396 | return Container::getInstance()->invokeClass($class, $args); |
397 | 397 | } else { |
398 | - throw new ClassNotFoundException('class not exists:' . $class, $class); |
|
398 | + throw new ClassNotFoundException('class not exists:'.$class, $class); |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | } |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | |
347 | 347 | return call_user_func_array($function, $args); |
348 | 348 | } catch (ReflectionException $e) { |
349 | - throw new Exception('function not exists: ' . $function . '()'); |
|
349 | + throw new Exception('function not exists: '.$function.'()'); |
|
350 | 350 | } |
351 | 351 | } |
352 | 352 | |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | $method[0] = get_class($method[0]); |
377 | 377 | } |
378 | 378 | |
379 | - throw new Exception('method not exists: ' . (is_array($method) ? $method[0] . '::' . $method[1] : $method) . '()'); |
|
379 | + throw new Exception('method not exists: '.(is_array($method) ? $method[0].'::'.$method[1] : $method).'()'); |
|
380 | 380 | } |
381 | 381 | } |
382 | 382 | |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | return $reflect->newInstanceArgs($args); |
440 | 440 | |
441 | 441 | } catch (ReflectionException $e) { |
442 | - throw new ClassNotFoundException('class not exists: ' . $class, $class); |
|
442 | + throw new ClassNotFoundException('class not exists: '.$class, $class); |
|
443 | 443 | } |
444 | 444 | } |
445 | 445 | |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | } elseif ($param->isDefaultValueAvailable()) { |
478 | 478 | $args[] = $param->getDefaultValue(); |
479 | 479 | } else { |
480 | - throw new InvalidArgumentException('method param miss:' . $name); |
|
480 | + throw new InvalidArgumentException('method param miss:'.$name); |
|
481 | 481 | } |
482 | 482 | } |
483 | 483 |
@@ -72,8 +72,7 @@ discard block |
||
72 | 72 | // 前置操作方法 即将废弃 |
73 | 73 | foreach ((array) $this->beforeActionList as $method => $options) { |
74 | 74 | is_numeric($method) ? |
75 | - $this->beforeAction($options) : |
|
76 | - $this->beforeAction($method, $options); |
|
75 | + $this->beforeAction($options) : $this->beforeAction($method, $options); |
|
77 | 76 | } |
78 | 77 | } |
79 | 78 | |
@@ -89,11 +88,11 @@ discard block |
||
89 | 88 | $only = $except = null; |
90 | 89 | |
91 | 90 | if (isset($val['only'])) { |
92 | - $only = array_map(function ($item) { |
|
91 | + $only = array_map(function($item) { |
|
93 | 92 | return strtolower($item); |
94 | 93 | }, $val['only']); |
95 | 94 | } elseif (isset($val['except'])) { |
96 | - $except = array_map(function ($item) { |
|
95 | + $except = array_map(function($item) { |
|
97 | 96 | return strtolower($item); |
98 | 97 | }, $val['except']); |
99 | 98 | } |
@@ -124,7 +123,7 @@ discard block |
||
124 | 123 | $options['only'] = explode(',', $options['only']); |
125 | 124 | } |
126 | 125 | |
127 | - $only = array_map(function ($val) { |
|
126 | + $only = array_map(function($val) { |
|
128 | 127 | return strtolower($val); |
129 | 128 | }, $options['only']); |
130 | 129 | |
@@ -136,7 +135,7 @@ discard block |
||
136 | 135 | $options['except'] = explode(',', $options['except']); |
137 | 136 | } |
138 | 137 | |
139 | - $except = array_map(function ($val) { |
|
138 | + $except = array_map(function($val) { |
|
140 | 139 | return strtolower($val); |
141 | 140 | }, $options['except']); |
142 | 141 |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $this->config = array_merge($this->config, (array) $config); |
45 | 45 | |
46 | 46 | if (empty($this->config['view_path'])) { |
47 | - $this->config['view_path'] = $app->getModulePath() . 'view' . DIRECTORY_SEPARATOR; |
|
47 | + $this->config['view_path'] = $app->getModulePath().'view'.DIRECTORY_SEPARATOR; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | $this->template = new Template($app, $this->config); |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | |
84 | 84 | // 模板不存在 抛出异常 |
85 | 85 | if (!is_file($template)) { |
86 | - throw new TemplateNotFoundException('template not exists:' . $template, $template); |
|
86 | + throw new TemplateNotFoundException('template not exists:'.$template, $template); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | // 记录视图信息 |
90 | 90 | $this->app |
91 | - ->log('[ VIEW ] ' . $template . ' [ ' . var_export(array_keys($data), true) . ' ]'); |
|
91 | + ->log('[ VIEW ] '.$template.' [ '.var_export(array_keys($data), true).' ]'); |
|
92 | 92 | |
93 | 93 | $this->template->fetch($template, $data, $config); |
94 | 94 | } |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | if ($this->config['view_base']) { |
127 | 127 | // 基础视图目录 |
128 | 128 | $module = isset($module) ? $module : $request->module(); |
129 | - $path = $this->config['view_base'] . ($module ? $module . DIRECTORY_SEPARATOR : ''); |
|
129 | + $path = $this->config['view_base'].($module ? $module.DIRECTORY_SEPARATOR : ''); |
|
130 | 130 | } else { |
131 | - $path = isset($module) ? $this->app->getAppPath() . $module . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR : $this->config['view_path']; |
|
131 | + $path = isset($module) ? $this->app->getAppPath().$module.DIRECTORY_SEPARATOR.'view'.DIRECTORY_SEPARATOR : $this->config['view_path']; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | $depr = $this->config['view_depr']; |
@@ -140,16 +140,16 @@ discard block |
||
140 | 140 | if ($controller) { |
141 | 141 | if ('' == $template) { |
142 | 142 | // 如果模板文件名为空 按照默认规则定位 |
143 | - $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $this->getActionTemplate($request); |
|
143 | + $template = str_replace('.', DIRECTORY_SEPARATOR, $controller).$depr.$this->getActionTemplate($request); |
|
144 | 144 | } elseif (false === strpos($template, $depr)) { |
145 | - $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template; |
|
145 | + $template = str_replace('.', DIRECTORY_SEPARATOR, $controller).$depr.$template; |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | } else { |
149 | 149 | $template = str_replace(['/', ':'], $depr, substr($template, 1)); |
150 | 150 | } |
151 | 151 | |
152 | - return $path . ltrim($template, '/') . '.' . ltrim($this->config['view_suffix'], '.'); |
|
152 | + return $path.ltrim($template, '/').'.'.ltrim($this->config['view_suffix'], '.'); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | protected function getActionTemplate($request) |