@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | */ |
137 | 137 | protected function getAvailablePageWrapper($url, $page) |
138 | 138 | { |
139 | - return '<li><a href="' . htmlentities($url) . '">' . $page . '</a></li>'; |
|
139 | + return '<li><a href="'.htmlentities($url).'">'.$page.'</a></li>'; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | */ |
148 | 148 | protected function getDisabledTextWrapper($text) |
149 | 149 | { |
150 | - return '<li class="disabled"><span>' . $text . '</span></li>'; |
|
150 | + return '<li class="disabled"><span>'.$text.'</span></li>'; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | */ |
159 | 159 | protected function getActivePageWrapper($text) |
160 | 160 | { |
161 | - return '<li class="active"><span>' . $text . '</span></li>'; |
|
161 | + return '<li class="active"><span>'.$text.'</span></li>'; |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function read($sessID) |
97 | 97 | { |
98 | - return (string) $this->handler->get($this->config['session_name'] . $sessID); |
|
98 | + return (string) $this->handler->get($this->config['session_name'].$sessID); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -108,9 +108,9 @@ discard block |
||
108 | 108 | public function write($sessID, $sessData) |
109 | 109 | { |
110 | 110 | if ($this->config['expire'] > 0) { |
111 | - $result = $this->handler->setex($this->config['session_name'] . $sessID, $this->config['expire'], $sessData); |
|
111 | + $result = $this->handler->setex($this->config['session_name'].$sessID, $this->config['expire'], $sessData); |
|
112 | 112 | } else { |
113 | - $result = $this->handler->set($this->config['session_name'] . $sessID, $sessData); |
|
113 | + $result = $this->handler->set($this->config['session_name'].$sessID, $sessData); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | return $result ? true : false; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function destroy($sessID) |
126 | 126 | { |
127 | - return $this->handler->delete($this->config['session_name'] . $sessID) > 0; |
|
127 | + return $this->handler->delete($this->config['session_name'].$sessID) > 0; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | $this->open('', ''); |
152 | 152 | } |
153 | 153 | |
154 | - $lockKey = 'LOCK_PREFIX_' . $sessID; |
|
154 | + $lockKey = 'LOCK_PREFIX_'.$sessID; |
|
155 | 155 | // 使用setnx操作加锁 |
156 | 156 | $isLock = $this->handler->setnx($lockKey, 1); |
157 | 157 | if ($isLock) { |
@@ -174,6 +174,6 @@ discard block |
||
174 | 174 | $this->open('', ''); |
175 | 175 | } |
176 | 176 | |
177 | - $this->handler->del('LOCK_PREFIX_' . $sessID); |
|
177 | + $this->handler->del('LOCK_PREFIX_'.$sessID); |
|
178 | 178 | } |
179 | 179 | } |
@@ -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"); |