@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function read($sessID) |
98 | 98 | { |
99 | - return (string) $this->handler->get($this->config['session_name'] . $sessID); |
|
99 | + return (string) $this->handler->get($this->config['session_name'].$sessID); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function write($sessID, $sessData) |
110 | 110 | { |
111 | - return $this->handler->set($this->config['session_name'] . $sessID, $sessData, $this->config['expire']); |
|
111 | + return $this->handler->set($this->config['session_name'].$sessID, $sessData, $this->config['expire']); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function destroy($sessID) |
121 | 121 | { |
122 | - return $this->handler->delete($this->config['session_name'] . $sessID); |
|
122 | + return $this->handler->delete($this->config['session_name'].$sessID); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -58,8 +58,7 @@ discard block |
||
58 | 58 | foreach ((array) $hosts as $i => $host) { |
59 | 59 | $port = isset($ports[$i]) ? $ports[$i] : $ports[0]; |
60 | 60 | $this->config['timeout'] > 0 ? |
61 | - $this->handler->addServer($host, $port, $this->config['persistent'], 1, $this->config['timeout']) : |
|
62 | - $this->handler->addServer($host, $port, $this->config['persistent'], 1); |
|
61 | + $this->handler->addServer($host, $port, $this->config['persistent'], 1, $this->config['timeout']) : $this->handler->addServer($host, $port, $this->config['persistent'], 1); |
|
63 | 62 | } |
64 | 63 | |
65 | 64 | return true; |
@@ -85,7 +84,7 @@ discard block |
||
85 | 84 | */ |
86 | 85 | public function read($sessID) |
87 | 86 | { |
88 | - return (string) $this->handler->get($this->config['session_name'] . $sessID); |
|
87 | + return (string) $this->handler->get($this->config['session_name'].$sessID); |
|
89 | 88 | } |
90 | 89 | |
91 | 90 | /** |
@@ -97,7 +96,7 @@ discard block |
||
97 | 96 | */ |
98 | 97 | public function write($sessID, $sessData) |
99 | 98 | { |
100 | - return $this->handler->set($this->config['session_name'] . $sessID, $sessData, 0, $this->config['expire']); |
|
99 | + return $this->handler->set($this->config['session_name'].$sessID, $sessData, 0, $this->config['expire']); |
|
101 | 100 | } |
102 | 101 | |
103 | 102 | /** |
@@ -108,7 +107,7 @@ discard block |
||
108 | 107 | */ |
109 | 108 | public function destroy($sessID) |
110 | 109 | { |
111 | - return $this->handler->delete($this->config['session_name'] . $sessID); |
|
110 | + return $this->handler->delete($this->config['session_name'].$sessID); |
|
112 | 111 | } |
113 | 112 | |
114 | 113 | /** |
@@ -323,7 +323,7 @@ |
||
323 | 323 | |
324 | 324 | // 全局作用域 |
325 | 325 | if (true === $useBaseQuery && method_exists($this, 'base')) { |
326 | - call_user_func_array([$this, 'base'], [ & $query]); |
|
326 | + call_user_func_array([$this, 'base'], [& $query]); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | $globalScope = is_array($useBaseQuery) && $useBaseQuery ? $useBaseQuery : $this->globalScope; |
@@ -356,10 +356,10 @@ discard block |
||
356 | 356 | return false; |
357 | 357 | } |
358 | 358 | |
359 | - $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
|
359 | + $path = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; |
|
360 | 360 | // 文件保存命名规则 |
361 | 361 | $saveName = $this->buildSaveName($savename, $autoAppendExt); |
362 | - $filename = $path . $saveName; |
|
362 | + $filename = $path.$saveName; |
|
363 | 363 | |
364 | 364 | // 检测目录 |
365 | 365 | if (false === $this->checkPath(dirname($filename))) { |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | } |
407 | 407 | |
408 | 408 | if ($autoAppendExt && false === strpos($savename, '.')) { |
409 | - $savename .= '.' . pathinfo($this->getInfo('name'), PATHINFO_EXTENSION); |
|
409 | + $savename .= '.'.pathinfo($this->getInfo('name'), PATHINFO_EXTENSION); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | return $savename; |
@@ -424,16 +424,16 @@ discard block |
||
424 | 424 | } else { |
425 | 425 | switch ($this->rule) { |
426 | 426 | case 'date': |
427 | - $savename = date('Ymd') . DIRECTORY_SEPARATOR . md5(microtime(true)); |
|
427 | + $savename = date('Ymd').DIRECTORY_SEPARATOR.md5(microtime(true)); |
|
428 | 428 | break; |
429 | 429 | default: |
430 | 430 | if (in_array($this->rule, hash_algos())) { |
431 | 431 | $hash = $this->hash($this->rule); |
432 | - $savename = substr($hash, 0, 2) . DIRECTORY_SEPARATOR . substr($hash, 2); |
|
432 | + $savename = substr($hash, 0, 2).DIRECTORY_SEPARATOR.substr($hash, 2); |
|
433 | 433 | } elseif (is_callable($this->rule)) { |
434 | 434 | $savename = call_user_func($this->rule); |
435 | 435 | } else { |
436 | - $savename = date('Ymd') . DIRECTORY_SEPARATOR . md5(microtime(true)); |
|
436 | + $savename = date('Ymd').DIRECTORY_SEPARATOR.md5(microtime(true)); |
|
437 | 437 | } |
438 | 438 | } |
439 | 439 | } |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | $domainName = is_array($name) ? array_shift($name) : $name; |
328 | 328 | |
329 | 329 | if ('*' != $domainName && false === strpos($domainName, '.')) { |
330 | - $domainName .= '.' . $this->request->rootDomain(); |
|
330 | + $domainName .= '.'.$this->request->rootDomain(); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | if (!isset($this->domains[$domainName])) { |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | $root = $this->request->rootDomain(); |
346 | 346 | foreach ($name as $item) { |
347 | 347 | if (false === strpos($item, '.')) { |
348 | - $item .= '.' . $root; |
|
348 | + $item .= '.'.$root; |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | $this->domains[$item] = $domainName; |
@@ -395,13 +395,13 @@ discard block |
||
395 | 395 | } elseif (true === $domain) { |
396 | 396 | return $this->bind; |
397 | 397 | } elseif (false === strpos($domain, '.')) { |
398 | - $domain .= '.' . $this->request->rootDomain(); |
|
398 | + $domain .= '.'.$this->request->rootDomain(); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | $subDomain = $this->request->subDomain(); |
402 | 402 | |
403 | 403 | if (strpos($subDomain, '.')) { |
404 | - $name = '*' . strstr($subDomain, '.'); |
|
404 | + $name = '*'.strstr($subDomain, '.'); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | if (isset($this->bind[$domain])) { |
@@ -709,10 +709,10 @@ discard block |
||
709 | 709 | $group = new RuleGroup($this, $this->group, $rule, null, $option, $pattern); |
710 | 710 | |
711 | 711 | foreach ($this->methodPrefix as $type => $val) { |
712 | - $group->addRule('<action>', $val . '<action>', $type); |
|
712 | + $group->addRule('<action>', $val.'<action>', $type); |
|
713 | 713 | } |
714 | 714 | |
715 | - return $group->prefix($route . '/'); |
|
715 | + return $group->prefix($route.'/'); |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | /** |
@@ -927,9 +927,9 @@ discard block |
||
927 | 927 | if ($subDomain && isset($this->domains[$subDomain])) { |
928 | 928 | // 子域名配置 |
929 | 929 | $item = $this->domains[$subDomain]; |
930 | - } elseif (isset($this->domains['*.' . $domain2]) && !empty($domain3)) { |
|
930 | + } elseif (isset($this->domains['*.'.$domain2]) && !empty($domain3)) { |
|
931 | 931 | // 泛三级域名 |
932 | - $item = $this->domains['*.' . $domain2]; |
|
932 | + $item = $this->domains['*.'.$domain2]; |
|
933 | 933 | $panDomain = $domain3; |
934 | 934 | } elseif (isset($this->domains['*']) && !empty($domain2)) { |
935 | 935 | // 泛二级域名 |
@@ -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); |