@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: liu21st <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\route; |
14 | 14 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | } |
191 | 191 | } |
192 | 192 | } elseif (false === strpos($domain, '.') && 0 !== strpos($domain, $rootDomain)) { |
193 | - $domain .= '.' . $rootDomain; |
|
193 | + $domain .= '.'.$rootDomain; |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | if (false !== strpos($domain, '://')) { |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $scheme = $this->https || $request->isSsl() ? 'https://' : 'http://'; |
200 | 200 | } |
201 | 201 | |
202 | - return $scheme . $domain; |
|
202 | + return $scheme.$domain; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
221 | - return (empty($suffix) || 0 === strpos($suffix, '.')) ? (string) $suffix : '.' . $suffix; |
|
221 | + return (empty($suffix) || 0 === strpos($suffix, '.')) ? (string) $suffix : '.'.$suffix; |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | { |
288 | 288 | $request = $this->app->request; |
289 | 289 | if (is_string($allowDomain) && false === strpos($allowDomain, '.')) { |
290 | - $allowDomain .= '.' . $request->rootDomain(); |
|
290 | + $allowDomain .= '.'.$request->rootDomain(); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | foreach ($rule as $item) { |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | } |
306 | 306 | |
307 | 307 | if (!in_array($request->port(), [80, 443])) { |
308 | - $domain .= ':' . $request->port(); |
|
308 | + $domain .= ':'.$request->port(); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | if (empty($pattern)) { |
@@ -316,12 +316,12 @@ discard block |
||
316 | 316 | |
317 | 317 | foreach ($pattern as $key => $val) { |
318 | 318 | if (isset($vars[$key])) { |
319 | - $url = str_replace(['[:' . $key . ']', '<' . $key . '?>', ':' . $key, '<' . $key . '>'], $type ? $vars[$key] : urlencode((string) $vars[$key]), $url); |
|
319 | + $url = str_replace(['[:'.$key.']', '<'.$key.'?>', ':'.$key, '<'.$key.'>'], $type ? $vars[$key] : urlencode((string) $vars[$key]), $url); |
|
320 | 320 | unset($vars[$key]); |
321 | 321 | $url = str_replace(['/?', '-?'], ['/', '-'], $url); |
322 | 322 | $result = [rtrim($url, '?/-'), $domain, $suffix]; |
323 | 323 | } elseif (2 == $val) { |
324 | - $url = str_replace(['/[:' . $key . ']', '[:' . $key . ']', '<' . $key . '?>'], '', $url); |
|
324 | + $url = str_replace(['/[:'.$key.']', '[:'.$key.']', '<'.$key.'?>'], '', $url); |
|
325 | 325 | $url = str_replace(['/?', '-?'], ['/', '-'], $url); |
326 | 326 | $result = [rtrim($url, '?/-'), $domain, $suffix]; |
327 | 327 | } else { |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | if (0 === strpos($url, '[') && $pos = strpos($url, ']')) { |
350 | 350 | // [name] 表示使用路由命名标识生成URL |
351 | 351 | $name = substr($url, 1, $pos - 1); |
352 | - $url = 'name' . substr($url, $pos + 1); |
|
352 | + $url = 'name'.substr($url, $pos + 1); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | if (false === strpos($url, '://') && 0 !== strpos($url, '/')) { |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | } |
377 | 377 | |
378 | 378 | if ($url) { |
379 | - $checkName = isset($name) ? $name : $url . (isset($info['query']) ? '?' . $info['query'] : ''); |
|
379 | + $checkName = isset($name) ? $name : $url.(isset($info['query']) ? '?'.$info['query'] : ''); |
|
380 | 380 | $checkDomain = $domain && is_string($domain) ? $domain : null; |
381 | 381 | |
382 | 382 | $rule = $this->route->getName($checkName, $checkDomain); |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | $suffix = $match[2]; |
403 | 403 | } |
404 | 404 | } elseif (!empty($rule) && isset($name)) { |
405 | - throw new \InvalidArgumentException('route name not exists:' . $name); |
|
405 | + throw new \InvalidArgumentException('route name not exists:'.$name); |
|
406 | 406 | } else { |
407 | 407 | // 检测URL绑定 |
408 | 408 | $bind = $this->route->getDomainBind($domain && is_string($domain) ? $domain : null); |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | $file = str_replace('\\', '/', dirname($file)); |
441 | 441 | } |
442 | 442 | |
443 | - $url = rtrim($file, '/') . '/' . $url; |
|
443 | + $url = rtrim($file, '/').'/'.$url; |
|
444 | 444 | |
445 | 445 | // URL后缀 |
446 | 446 | if ('/' == substr($url, -1) || '' == $url) { |
@@ -450,32 +450,32 @@ discard block |
||
450 | 450 | } |
451 | 451 | |
452 | 452 | // 锚点 |
453 | - $anchor = !empty($anchor) ? '#' . $anchor : ''; |
|
453 | + $anchor = !empty($anchor) ? '#'.$anchor : ''; |
|
454 | 454 | |
455 | 455 | // 参数组装 |
456 | 456 | if (!empty($vars)) { |
457 | 457 | // 添加参数 |
458 | 458 | if ($this->route->config('url_common_param')) { |
459 | 459 | $vars = http_build_query($vars); |
460 | - $url .= $suffix . '?' . $vars . $anchor; |
|
460 | + $url .= $suffix.'?'.$vars.$anchor; |
|
461 | 461 | } else { |
462 | 462 | foreach ($vars as $var => $val) { |
463 | 463 | if ('' !== $val) { |
464 | - $url .= $depr . $var . $depr . urlencode((string) $val); |
|
464 | + $url .= $depr.$var.$depr.urlencode((string) $val); |
|
465 | 465 | } |
466 | 466 | } |
467 | 467 | |
468 | - $url .= $suffix . $anchor; |
|
468 | + $url .= $suffix.$anchor; |
|
469 | 469 | } |
470 | 470 | } else { |
471 | - $url .= $suffix . $anchor; |
|
471 | + $url .= $suffix.$anchor; |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | // 检测域名 |
475 | 475 | $domain = $this->parseDomain($url, $domain); |
476 | 476 | |
477 | 477 | // URL组装 |
478 | - return $domain . rtrim($this->root, '/') . '/' . ltrim($url, '/'); |
|
478 | + return $domain.rtrim($this->root, '/').'/'.ltrim($url, '/'); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | public function __toString() |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: yunwuxin <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\console; |
14 | 14 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | ]; |
405 | 405 | $replacements = [ |
406 | 406 | $name, |
407 | - $_SERVER['PHP_SELF'] . ' ' . $name, |
|
407 | + $_SERVER['PHP_SELF'].' '.$name, |
|
408 | 408 | ]; |
409 | 409 | |
410 | 410 | return str_replace($placeholders, $replacements, $this->getHelp()); |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: liu21st <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\view\driver; |
14 | 14 | |
@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | |
79 | 79 | // 模板不存在 抛出异常 |
80 | 80 | if (!is_file($template)) { |
81 | - throw new RuntimeException('template not exists:' . $template); |
|
81 | + throw new RuntimeException('template not exists:'.$template); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | $this->template = $template; |
85 | 85 | |
86 | 86 | // 记录视图信息 |
87 | 87 | $this->app->log |
88 | - ->record('[ VIEW ] ' . $template . ' [ ' . var_export(array_keys($data), true) . ' ]'); |
|
88 | + ->record('[ VIEW ] '.$template.' [ '.var_export(array_keys($data), true).' ]'); |
|
89 | 89 | |
90 | 90 | extract($data, EXTR_OVERWRITE); |
91 | 91 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $this->content = $content; |
105 | 105 | |
106 | 106 | extract($data, EXTR_OVERWRITE); |
107 | - eval('?>' . $this->content); |
|
107 | + eval('?>'.$this->content); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -129,10 +129,10 @@ discard block |
||
129 | 129 | $appName = isset($app) ? $app : $this->app->http->getName(); |
130 | 130 | $view = $this->config['view_dir_name']; |
131 | 131 | |
132 | - if (is_dir($this->app->getAppPath() . $view)) { |
|
133 | - $path = isset($app) ? $this->app->getBasePath() . ($appName ? $appName . DIRECTORY_SEPARATOR : '') . $view . DIRECTORY_SEPARATOR : $this->app->getAppPath() . $view . DIRECTORY_SEPARATOR; |
|
132 | + if (is_dir($this->app->getAppPath().$view)) { |
|
133 | + $path = isset($app) ? $this->app->getBasePath().($appName ? $appName.DIRECTORY_SEPARATOR : '').$view.DIRECTORY_SEPARATOR : $this->app->getAppPath().$view.DIRECTORY_SEPARATOR; |
|
134 | 134 | } else { |
135 | - $path = $this->app->getRootPath() . $view . DIRECTORY_SEPARATOR . ($appName ? $appName . DIRECTORY_SEPARATOR : ''); |
|
135 | + $path = $this->app->getRootPath().$view.DIRECTORY_SEPARATOR.($appName ? $appName.DIRECTORY_SEPARATOR : ''); |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $controller = $request->controller(); |
144 | 144 | if (strpos($controller, '.')) { |
145 | 145 | $pos = strrpos($controller, '.'); |
146 | - $controller = substr($controller, 0, $pos) . '.' . Str::snake(substr($controller, $pos + 1)); |
|
146 | + $controller = substr($controller, 0, $pos).'.'.Str::snake(substr($controller, $pos + 1)); |
|
147 | 147 | } else { |
148 | 148 | $controller = Str::snake($controller); |
149 | 149 | } |
@@ -159,16 +159,16 @@ discard block |
||
159 | 159 | $template = Str::snake($request->action()); |
160 | 160 | } |
161 | 161 | |
162 | - $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template; |
|
162 | + $template = str_replace('.', DIRECTORY_SEPARATOR, $controller).$depr.$template; |
|
163 | 163 | } elseif (false === strpos($template, $depr)) { |
164 | - $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template; |
|
164 | + $template = str_replace('.', DIRECTORY_SEPARATOR, $controller).$depr.$template; |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | } else { |
168 | 168 | $template = str_replace(['/', ':'], $depr, substr($template, 1)); |
169 | 169 | } |
170 | 170 | |
171 | - return $path . ltrim($template, '/') . '.' . ltrim($this->config['view_suffix'], '.'); |
|
171 | + return $path.ltrim($template, '/').'.'.ltrim($this->config['view_suffix'], '.'); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -48,21 +48,21 @@ discard block |
||
48 | 48 | $tables = $this->app->db->getConnection()->getTables($dbName); |
49 | 49 | } else { |
50 | 50 | if ($dir) { |
51 | - $appPath = $this->app->getBasePath() . $dir . DIRECTORY_SEPARATOR; |
|
52 | - $namespace = 'app\\' . $dir; |
|
51 | + $appPath = $this->app->getBasePath().$dir.DIRECTORY_SEPARATOR; |
|
52 | + $namespace = 'app\\'.$dir; |
|
53 | 53 | } else { |
54 | 54 | $appPath = $this->app->getBasePath(); |
55 | 55 | $namespace = 'app'; |
56 | 56 | } |
57 | 57 | |
58 | - $path = $appPath . 'model'; |
|
58 | + $path = $appPath.'model'; |
|
59 | 59 | $list = is_dir($path) ? scandir($path) : []; |
60 | 60 | |
61 | 61 | foreach ($list as $file) { |
62 | 62 | if (0 === strpos($file, '.')) { |
63 | 63 | continue; |
64 | 64 | } |
65 | - $class = '\\' . $namespace . '\\model\\' . pathinfo($file, PATHINFO_FILENAME); |
|
65 | + $class = '\\'.$namespace.'\\model\\'.pathinfo($file, PATHINFO_FILENAME); |
|
66 | 66 | $this->buildModelSchema($class); |
67 | 67 | } |
68 | 68 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | return; |
71 | 71 | } |
72 | 72 | |
73 | - $db = isset($dbName) ? $dbName . '.' : ''; |
|
73 | + $db = isset($dbName) ? $dbName.'.' : ''; |
|
74 | 74 | $this->buildDataBaseSchema($schemaPath, $tables, $db); |
75 | 75 | |
76 | 76 | $output->writeln('<info>Succeed!</info>'); |
@@ -89,27 +89,27 @@ discard block |
||
89 | 89 | if (!is_dir($path)) { |
90 | 90 | mkdir($path, 0755, true); |
91 | 91 | } |
92 | - $content = '<?php ' . PHP_EOL . 'return '; |
|
92 | + $content = '<?php '.PHP_EOL.'return '; |
|
93 | 93 | $info = $model->db()->getConnection()->getTableFieldsInfo($table); |
94 | - $content .= var_export($info, true) . ';'; |
|
94 | + $content .= var_export($info, true).';'; |
|
95 | 95 | |
96 | - file_put_contents($path . $dbName . '.' . $table . '.php', $content); |
|
96 | + file_put_contents($path.$dbName.'.'.$table.'.php', $content); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | 100 | protected function buildDataBaseSchema(string $path, array $tables, string $db): void |
101 | 101 | { |
102 | 102 | if ('' == $db) { |
103 | - $dbName = $this->app->db->getConnection()->getConfig('database') . '.'; |
|
103 | + $dbName = $this->app->db->getConnection()->getConfig('database').'.'; |
|
104 | 104 | } else { |
105 | 105 | $dbName = $db; |
106 | 106 | } |
107 | 107 | |
108 | 108 | foreach ($tables as $table) { |
109 | - $content = '<?php ' . PHP_EOL . 'return '; |
|
110 | - $info = $this->app->db->getConnection()->getTableFieldsInfo($db . $table); |
|
111 | - $content .= var_export($info, true) . ';'; |
|
112 | - file_put_contents($path . $dbName . $table . '.php', $content); |
|
109 | + $content = '<?php '.PHP_EOL.'return '; |
|
110 | + $info = $this->app->db->getConnection()->getTableFieldsInfo($db.$table); |
|
111 | + $content .= var_export($info, true).';'; |
|
112 | + file_put_contents($path.$dbName.$table.'.php', $content); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | } |
@@ -35,18 +35,18 @@ discard block |
||
35 | 35 | if ($input->getOption('route')) { |
36 | 36 | $this->app->cache->clear('route_cache'); |
37 | 37 | } else { |
38 | - $runtimePath = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR; |
|
38 | + $runtimePath = $this->app->getRootPath().'runtime'.DIRECTORY_SEPARATOR; |
|
39 | 39 | |
40 | 40 | if ($input->getOption('cache')) { |
41 | - $path = $runtimePath . 'cache'; |
|
41 | + $path = $runtimePath.'cache'; |
|
42 | 42 | } elseif ($input->getOption('log')) { |
43 | - $path = $runtimePath . 'log'; |
|
43 | + $path = $runtimePath.'log'; |
|
44 | 44 | } else { |
45 | 45 | $path = $input->getOption('path') ?: $runtimePath; |
46 | 46 | } |
47 | 47 | |
48 | 48 | $rmdir = $input->getOption('dir') ? true : false; |
49 | - $this->clear(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR, $rmdir); |
|
49 | + $this->clear(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR, $rmdir); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $output->writeln("<info>Clear Successed</info>"); |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | $files = is_dir($path) ? scandir($path) : []; |
58 | 58 | |
59 | 59 | foreach ($files as $file) { |
60 | - if ('.' != $file && '..' != $file && is_dir($path . $file)) { |
|
61 | - array_map('unlink', glob($path . $file . DIRECTORY_SEPARATOR . '*.*')); |
|
60 | + if ('.' != $file && '..' != $file && is_dir($path.$file)) { |
|
61 | + array_map('unlink', glob($path.$file.DIRECTORY_SEPARATOR.'*.*')); |
|
62 | 62 | if ($rmdir) { |
63 | - rmdir($path . $file); |
|
63 | + rmdir($path.$file); |
|
64 | 64 | } |
65 | - } elseif ('.gitignore' != $file && is_file($path . $file)) { |
|
66 | - unlink($path . $file); |
|
65 | + } elseif ('.gitignore' != $file && is_file($path.$file)) { |
|
66 | + unlink($path.$file); |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $this->basePath = $this->app->getBasePath(); |
41 | 41 | $dir = $input->getArgument('dir') ?: ''; |
42 | 42 | |
43 | - $list = include $this->basePath . 'build.php'; |
|
43 | + $list = include $this->basePath.'build.php'; |
|
44 | 44 | |
45 | 45 | if (empty($list)) { |
46 | 46 | $output->writeln("Build file Is Empty"); |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | */ |
62 | 62 | protected function buildApp(string $dir, array $list = []): void |
63 | 63 | { |
64 | - if (!is_dir($this->basePath . $dir)) { |
|
64 | + if (!is_dir($this->basePath.$dir)) { |
|
65 | 65 | // 创建应用目录 |
66 | - mkdir($this->basePath . $dir); |
|
66 | + mkdir($this->basePath.$dir); |
|
67 | 67 | } |
68 | 68 | |
69 | - $appPath = $this->basePath . ($dir ? $dir . DIRECTORY_SEPARATOR : ''); |
|
70 | - $namespace = 'app' . ($dir ? '\\' . $dir : ''); |
|
69 | + $appPath = $this->basePath.($dir ? $dir.DIRECTORY_SEPARATOR : ''); |
|
70 | + $namespace = 'app'.($dir ? '\\'.$dir : ''); |
|
71 | 71 | |
72 | 72 | // 创建配置文件和公共文件 |
73 | 73 | $this->buildCommon($dir); |
@@ -78,41 +78,41 @@ discard block |
||
78 | 78 | if ('__dir__' == $path) { |
79 | 79 | // 生成子目录 |
80 | 80 | foreach ($file as $dir) { |
81 | - $this->checkDirBuild($appPath . $dir); |
|
81 | + $this->checkDirBuild($appPath.$dir); |
|
82 | 82 | } |
83 | 83 | } elseif ('__file__' == $path) { |
84 | 84 | // 生成(空白)文件 |
85 | 85 | foreach ($file as $name) { |
86 | - if (!is_file($appPath . $name)) { |
|
87 | - file_put_contents($appPath . $name, 'php' == pathinfo($name, PATHINFO_EXTENSION) ? '<?php' . PHP_EOL : ''); |
|
86 | + if (!is_file($appPath.$name)) { |
|
87 | + file_put_contents($appPath.$name, 'php' == pathinfo($name, PATHINFO_EXTENSION) ? '<?php'.PHP_EOL : ''); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | } else { |
91 | 91 | // 生成相关MVC文件 |
92 | 92 | foreach ($file as $val) { |
93 | 93 | $val = trim($val); |
94 | - $filename = $appPath . $path . DIRECTORY_SEPARATOR . $val . '.php'; |
|
95 | - $space = $namespace . '\\' . $path; |
|
94 | + $filename = $appPath.$path.DIRECTORY_SEPARATOR.$val.'.php'; |
|
95 | + $space = $namespace.'\\'.$path; |
|
96 | 96 | $class = $val; |
97 | 97 | switch ($path) { |
98 | 98 | case 'controller': // 控制器 |
99 | 99 | if ($this->app->config->get('route.controller_suffix')) { |
100 | - $filename = $appPath . $path . DIRECTORY_SEPARATOR . $val . 'Controller.php'; |
|
101 | - $class = $val . 'Controller'; |
|
100 | + $filename = $appPath.$path.DIRECTORY_SEPARATOR.$val.'Controller.php'; |
|
101 | + $class = $val.'Controller'; |
|
102 | 102 | } |
103 | - $content = "<?php" . PHP_EOL . "namespace {$space};" . PHP_EOL . PHP_EOL . "class {$class}" . PHP_EOL . "{" . PHP_EOL . PHP_EOL . "}"; |
|
103 | + $content = "<?php".PHP_EOL."namespace {$space};".PHP_EOL.PHP_EOL."class {$class}".PHP_EOL."{".PHP_EOL.PHP_EOL."}"; |
|
104 | 104 | break; |
105 | 105 | case 'model': // 模型 |
106 | - $content = "<?php" . PHP_EOL . "namespace {$space};" . PHP_EOL . PHP_EOL . "use think\Model;" . PHP_EOL . PHP_EOL . "class {$class} extends Model" . PHP_EOL . "{" . PHP_EOL . PHP_EOL . "}"; |
|
106 | + $content = "<?php".PHP_EOL."namespace {$space};".PHP_EOL.PHP_EOL."use think\Model;".PHP_EOL.PHP_EOL."class {$class} extends Model".PHP_EOL."{".PHP_EOL.PHP_EOL."}"; |
|
107 | 107 | break; |
108 | 108 | case 'view': // 视图 |
109 | - $filename = $appPath . $path . DIRECTORY_SEPARATOR . $val . '.html'; |
|
109 | + $filename = $appPath.$path.DIRECTORY_SEPARATOR.$val.'.html'; |
|
110 | 110 | $this->checkDirBuild(dirname($filename)); |
111 | 111 | $content = ''; |
112 | 112 | break; |
113 | 113 | default: |
114 | 114 | // 其他文件 |
115 | - $content = "<?php" . PHP_EOL . "namespace {$space};" . PHP_EOL . PHP_EOL . "class {$class}" . PHP_EOL . "{" . PHP_EOL . PHP_EOL . "}"; |
|
115 | + $content = "<?php".PHP_EOL."namespace {$space};".PHP_EOL.PHP_EOL."class {$class}".PHP_EOL."{".PHP_EOL.PHP_EOL."}"; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | if (!is_file($filename)) { |
@@ -133,10 +133,10 @@ discard block |
||
133 | 133 | protected function buildHello(string $dir, string $namespace): void |
134 | 134 | { |
135 | 135 | $suffix = $this->app->config->get('route.controller_suffix') ? 'Controller' : ''; |
136 | - $filename = $this->basePath . ($dir ? $dir . DIRECTORY_SEPARATOR : '') . 'controller' . DIRECTORY_SEPARATOR . 'Index' . $suffix . '.php'; |
|
136 | + $filename = $this->basePath.($dir ? $dir.DIRECTORY_SEPARATOR : '').'controller'.DIRECTORY_SEPARATOR.'Index'.$suffix.'.php'; |
|
137 | 137 | |
138 | 138 | if (!is_file($filename)) { |
139 | - $content = file_get_contents($this->app->getThinkPath() . 'tpl' . DIRECTORY_SEPARATOR . 'default_index.tpl'); |
|
139 | + $content = file_get_contents($this->app->getThinkPath().'tpl'.DIRECTORY_SEPARATOR.'default_index.tpl'); |
|
140 | 140 | $content = str_replace(['{%name%}', '{%app%}', '{%layer%}', '{%suffix%}'], [$dir, $namespace, 'controller', $suffix], $content); |
141 | 141 | $this->checkDirBuild(dirname($filename)); |
142 | 142 | |
@@ -152,15 +152,15 @@ discard block |
||
152 | 152 | */ |
153 | 153 | protected function buildCommon(string $dir): void |
154 | 154 | { |
155 | - $appPath = $this->basePath . ($dir ? $dir . DIRECTORY_SEPARATOR : ''); |
|
155 | + $appPath = $this->basePath.($dir ? $dir.DIRECTORY_SEPARATOR : ''); |
|
156 | 156 | |
157 | - if (!is_file($appPath . 'common.php')) { |
|
158 | - file_put_contents($appPath . 'common.php', "<?php" . PHP_EOL . "// 这是系统自动生成的公共文件" . PHP_EOL); |
|
157 | + if (!is_file($appPath.'common.php')) { |
|
158 | + file_put_contents($appPath.'common.php', "<?php".PHP_EOL."// 这是系统自动生成的公共文件".PHP_EOL); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | foreach (['event', 'middleware', 'provider'] as $name) { |
162 | - if (!is_file($appPath . $name . '.php')) { |
|
163 | - file_put_contents($appPath . $name . '.php', "<?php" . PHP_EOL . "// 这是系统自动生成的{$name}定义文件" . PHP_EOL . "return [" . PHP_EOL . PHP_EOL . "];" . PHP_EOL); |
|
162 | + if (!is_file($appPath.$name.'.php')) { |
|
163 | + file_put_contents($appPath.$name.'.php', "<?php".PHP_EOL."// 这是系统自动生成的{$name}定义文件".PHP_EOL."return [".PHP_EOL.PHP_EOL."];".PHP_EOL); |
|
164 | 164 | } |
165 | 165 | } |
166 | 166 | } |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | { |
30 | 30 | $dir = $input->getArgument('dir') ?: ''; |
31 | 31 | |
32 | - $path = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . ($dir ? $dir . DIRECTORY_SEPARATOR : ''); |
|
32 | + $path = $this->app->getRootPath().'runtime'.DIRECTORY_SEPARATOR.($dir ? $dir.DIRECTORY_SEPARATOR : ''); |
|
33 | 33 | |
34 | - $filename = $path . 'route.php'; |
|
34 | + $filename = $path.'route.php'; |
|
35 | 35 | if (is_file($filename)) { |
36 | 36 | unlink($filename); |
37 | 37 | } |
@@ -46,21 +46,21 @@ discard block |
||
46 | 46 | $this->app->route->lazy(false); |
47 | 47 | |
48 | 48 | // 路由检测 |
49 | - $path = $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR . ($dir ? $dir . DIRECTORY_SEPARATOR : ''); |
|
49 | + $path = $this->app->getRootPath().'route'.DIRECTORY_SEPARATOR.($dir ? $dir.DIRECTORY_SEPARATOR : ''); |
|
50 | 50 | |
51 | 51 | $files = is_dir($path) ? scandir($path) : []; |
52 | 52 | |
53 | 53 | foreach ($files as $file) { |
54 | 54 | if (strpos($file, '.php')) { |
55 | - include $path . $file; |
|
55 | + include $path.$file; |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
59 | 59 | //触发路由载入完成事件 |
60 | 60 | $this->app->event->trigger(RouteLoaded::class); |
61 | 61 | |
62 | - $content = '<?php ' . PHP_EOL . 'return '; |
|
63 | - $content .= '\Opis\Closure\unserialize(\'' . \Opis\Closure\serialize($this->app->route->getName()) . '\');'; |
|
62 | + $content = '<?php '.PHP_EOL.'return '; |
|
63 | + $content .= '\Opis\Closure\unserialize(\''.\Opis\Closure\serialize($this->app->route->getName()).'\');'; |
|
64 | 64 | return $content; |
65 | 65 | } |
66 | 66 |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | { |
43 | 43 | $dir = $input->getArgument('dir') ?: ''; |
44 | 44 | |
45 | - $filename = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . ($dir ? $dir . DIRECTORY_SEPARATOR : '') . 'route_list.php'; |
|
45 | + $filename = $this->app->getRootPath().'runtime'.DIRECTORY_SEPARATOR.($dir ? $dir.DIRECTORY_SEPARATOR : '').'route_list.php'; |
|
46 | 46 | |
47 | 47 | if (is_file($filename)) { |
48 | 48 | unlink($filename); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | $content = $this->getRouteList($dir); |
54 | - file_put_contents($filename, 'Route List' . PHP_EOL . $content); |
|
54 | + file_put_contents($filename, 'Route List'.PHP_EOL.$content); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | protected function getRouteList(string $dir = null): string |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | $this->app->route->clear(); |
61 | 61 | |
62 | 62 | if ($dir) { |
63 | - $path = $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR; |
|
63 | + $path = $this->app->getRootPath().'route'.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR; |
|
64 | 64 | } else { |
65 | - $path = $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR; |
|
65 | + $path = $this->app->getRootPath().'route'.DIRECTORY_SEPARATOR; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | $files = is_dir($path) ? scandir($path) : []; |
69 | 69 | |
70 | 70 | foreach ($files as $file) { |
71 | 71 | if (strpos($file, '.php')) { |
72 | - include $path . $file; |
|
72 | + include $path.$file; |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $sort = $this->sortBy[$sort]; |
109 | 109 | } |
110 | 110 | |
111 | - uasort($rows, function ($a, $b) use ($sort) { |
|
111 | + uasort($rows, function($a, $b) use ($sort) { |
|
112 | 112 | $itemA = $a[$sort] ?? null; |
113 | 113 | $itemB = $b[$sort] ?? null; |
114 | 114 |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | |
65 | 65 | $this->middleware->add('foo'); |
66 | 66 | $this->assertEquals(3, count($this->middleware->all())); |
67 | - $this->middleware->add(function () { |
|
67 | + $this->middleware->add(function() { |
|
68 | 68 | }); |
69 | - $this->middleware->add(function () { |
|
69 | + $this->middleware->add(function() { |
|
70 | 70 | }); |
71 | 71 | $this->assertEquals(5, count($this->middleware->all())); |
72 | 72 | } |
@@ -85,10 +85,10 @@ discard block |
||
85 | 85 | $handle->shouldReceive('report')->with($e)->andReturnNull(); |
86 | 86 | $handle->shouldReceive('render')->with($request, $e)->andReturn($response); |
87 | 87 | |
88 | - $foo->shouldReceive('handle')->once()->andReturnUsing(function ($request, $next) { |
|
88 | + $foo->shouldReceive('handle')->once()->andReturnUsing(function($request, $next) { |
|
89 | 89 | return $next($request); |
90 | 90 | }); |
91 | - $bar->shouldReceive('handle')->once()->andReturnUsing(function ($request, $next) use ($e) { |
|
91 | + $bar->shouldReceive('handle')->once()->andReturnUsing(function($request, $next) use ($e) { |
|
92 | 92 | $next($request); |
93 | 93 | throw $e; |
94 | 94 | }); |
@@ -99,13 +99,13 @@ discard block |
||
99 | 99 | |
100 | 100 | $this->config->shouldReceive('get')->once()->with('middleware.priority', [])->andReturn(['FooMiddleware', 'BarMiddleware']); |
101 | 101 | |
102 | - $this->middleware->import([function ($request, $next) { |
|
102 | + $this->middleware->import([function($request, $next) { |
|
103 | 103 | return $next($request); |
104 | 104 | }, 'BarMiddleware', 'FooMiddleware']); |
105 | 105 | |
106 | 106 | $this->assertInstanceOf(Pipeline::class, $pipeline = $this->middleware->pipeline()); |
107 | 107 | |
108 | - $pipeline->send($request)->then(function ($request) use ($e, $response) { |
|
108 | + $pipeline->send($request)->then(function($request) use ($e, $response) { |
|
109 | 109 | throw $e; |
110 | 110 | }); |
111 | 111 |