@@ -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 | } |