@@ -54,21 +54,21 @@ discard block |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | if ($app) { |
57 | - $appPath = $this->app->getBasePath() . $app . DIRECTORY_SEPARATOR; |
|
58 | - $namespace = 'app\\' . $app; |
|
57 | + $appPath = $this->app->getBasePath().$app.DIRECTORY_SEPARATOR; |
|
58 | + $namespace = 'app\\'.$app; |
|
59 | 59 | } else { |
60 | 60 | $appPath = $this->app->getBasePath(); |
61 | 61 | $namespace = 'app'; |
62 | 62 | } |
63 | 63 | |
64 | - $path = $appPath . 'model'; |
|
64 | + $path = $appPath.'model'; |
|
65 | 65 | $list = is_dir($path) ? scandir($path) : []; |
66 | 66 | |
67 | 67 | foreach ($list as $file) { |
68 | 68 | if (0 === strpos($file, '.')) { |
69 | 69 | continue; |
70 | 70 | } |
71 | - $class = '\\' . $namespace . '\\model\\' . pathinfo($file, PATHINFO_FILENAME); |
|
71 | + $class = '\\'.$namespace.'\\model\\'.pathinfo($file, PATHINFO_FILENAME); |
|
72 | 72 | $this->buildModelSchema($class); |
73 | 73 | } |
74 | 74 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | return; |
77 | 77 | } |
78 | 78 | |
79 | - $db = isset($dbName) ? $dbName . '.' : ''; |
|
79 | + $db = isset($dbName) ? $dbName.'.' : ''; |
|
80 | 80 | $this->buildDataBaseSchema($schemaPath, $tables, $db); |
81 | 81 | |
82 | 82 | $output->writeln('<info>Succeed!</info>'); |
@@ -93,27 +93,27 @@ discard block |
||
93 | 93 | $table = $model->getTable(); |
94 | 94 | $dbName = $model->getConnection()->getConfig('database'); |
95 | 95 | $path = $model->getConnection()->getConfig('schema_cache_path'); |
96 | - $content = '<?php ' . PHP_EOL . 'return '; |
|
96 | + $content = '<?php '.PHP_EOL.'return '; |
|
97 | 97 | $info = $model->db()->getConnection()->getFields($table); |
98 | - $content .= var_export($info, true) . ';'; |
|
98 | + $content .= var_export($info, true).';'; |
|
99 | 99 | |
100 | - file_put_contents($path . $dbName . '.' . $table . '.php', $content); |
|
100 | + file_put_contents($path.$dbName.'.'.$table.'.php', $content); |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | 104 | protected function buildDataBaseSchema(string $path, array $tables, string $db): void |
105 | 105 | { |
106 | 106 | if ('' == $db) { |
107 | - $dbName = $this->app->db->getConnection()->getConfig('database') . '.'; |
|
107 | + $dbName = $this->app->db->getConnection()->getConfig('database').'.'; |
|
108 | 108 | } else { |
109 | 109 | $dbName = $db; |
110 | 110 | } |
111 | 111 | |
112 | 112 | foreach ($tables as $table) { |
113 | - $content = '<?php ' . PHP_EOL . 'return '; |
|
114 | - $info = $this->app->db->getConnection()->getFields($db . $table); |
|
115 | - $content .= var_export($info, true) . ';'; |
|
116 | - file_put_contents($path . $dbName . $table . '.php', $content); |
|
113 | + $content = '<?php '.PHP_EOL.'return '; |
|
114 | + $info = $this->app->db->getConnection()->getFields($db.$table); |
|
115 | + $content .= var_export($info, true).';'; |
|
116 | + file_put_contents($path.$dbName.$table.'.php', $content); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | } |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | return false; |
35 | 35 | } |
36 | 36 | |
37 | - $path = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . ($app ? $app . DIRECTORY_SEPARATOR : ''); |
|
37 | + $path = $this->app->getRootPath().'runtime'.DIRECTORY_SEPARATOR.($app ? $app.DIRECTORY_SEPARATOR : ''); |
|
38 | 38 | |
39 | - $filename = $path . 'route.php'; |
|
39 | + $filename = $path.'route.php'; |
|
40 | 40 | if (is_file($filename)) { |
41 | 41 | unlink($filename); |
42 | 42 | } |
@@ -51,21 +51,21 @@ discard block |
||
51 | 51 | $this->app->route->lazy(false); |
52 | 52 | |
53 | 53 | // 路由检测 |
54 | - $path = $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR . ($app ? $app . DIRECTORY_SEPARATOR : ''); |
|
54 | + $path = $this->app->getRootPath().'route'.DIRECTORY_SEPARATOR.($app ? $app.DIRECTORY_SEPARATOR : ''); |
|
55 | 55 | |
56 | 56 | $files = is_dir($path) ? scandir($path) : []; |
57 | 57 | |
58 | 58 | foreach ($files as $file) { |
59 | 59 | if (strpos($file, '.php')) { |
60 | - include $path . $file; |
|
60 | + include $path.$file; |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | 64 | //触发路由载入完成事件 |
65 | 65 | $this->app->event->trigger(RouteLoaded::class); |
66 | 66 | |
67 | - $content = '<?php ' . PHP_EOL . 'return '; |
|
68 | - $content .= '\Opis\Closure\unserialize(\'' . \Opis\Closure\serialize($this->app->route->getName()) . '\');'; |
|
67 | + $content = '<?php '.PHP_EOL.'return '; |
|
68 | + $content .= '\Opis\Closure\unserialize(\''.\Opis\Closure\serialize($this->app->route->getName()).'\');'; |
|
69 | 69 | return $content; |
70 | 70 | } |
71 | 71 |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | if ($app) { |
51 | - $filename = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . $app . DIRECTORY_SEPARATOR . 'route_list_' . $app . '.php'; |
|
51 | + $filename = $this->app->getRootPath().'runtime'.DIRECTORY_SEPARATOR.$app.DIRECTORY_SEPARATOR.'route_list_'.$app.'.php'; |
|
52 | 52 | } else { |
53 | - $filename = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . 'route_list.php'; |
|
53 | + $filename = $this->app->getRootPath().'runtime'.DIRECTORY_SEPARATOR.'route_list.php'; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | if (is_file($filename)) { |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | $content = $this->getRouteList($app); |
63 | - file_put_contents($filename, 'Route List' . PHP_EOL . $content); |
|
63 | + file_put_contents($filename, 'Route List'.PHP_EOL.$content); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | protected function getRouteList(string $app = null): string |
@@ -69,16 +69,16 @@ discard block |
||
69 | 69 | $this->app->route->clear(); |
70 | 70 | |
71 | 71 | if ($app) { |
72 | - $path = $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR . $app . DIRECTORY_SEPARATOR; |
|
72 | + $path = $this->app->getRootPath().'route'.DIRECTORY_SEPARATOR.$app.DIRECTORY_SEPARATOR; |
|
73 | 73 | } else { |
74 | - $path = $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR; |
|
74 | + $path = $this->app->getRootPath().'route'.DIRECTORY_SEPARATOR; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | $files = is_dir($path) ? scandir($path) : []; |
78 | 78 | |
79 | 79 | foreach ($files as $file) { |
80 | 80 | if (strpos($file, '.php')) { |
81 | - include $path . $file; |
|
81 | + include $path.$file; |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $sort = $this->sortBy[$sort]; |
118 | 118 | } |
119 | 119 | |
120 | - uasort($rows, function ($a, $b) use ($sort) { |
|
120 | + uasort($rows, function($a, $b) use ($sort) { |
|
121 | 121 | $itemA = $a[$sort] ?? null; |
122 | 122 | $itemB = $b[$sort] ?? null; |
123 | 123 |
@@ -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()); |
@@ -508,6 +508,6 @@ discard block |
||
508 | 508 | protected function isMultiApp(): bool |
509 | 509 | { |
510 | 510 | $autoMulti = $this->app->config->get('app.auto_multi_app', false); |
511 | - return $autoMulti || !is_dir($this->app->getBasePath() . 'controller'); |
|
511 | + return $autoMulti || !is_dir($this->app->getBasePath().'controller'); |
|
512 | 512 | } |
513 | 513 | } |
@@ -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; |
14 | 14 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | public function __construct(App $app) |
58 | 58 | { |
59 | 59 | $this->app = $app; |
60 | - $this->multi = is_dir($this->app->getBasePath() . 'controller') ? false : true; |
|
60 | + $this->multi = is_dir($this->app->getBasePath().'controller') ? false : true; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | $this->initialize(); |
174 | 174 | |
175 | 175 | // 加载全局中间件 |
176 | - if (is_file($this->app->getBasePath() . 'middleware.php')) { |
|
177 | - $this->app->middleware->import(include $this->app->getBasePath() . 'middleware.php'); |
|
176 | + if (is_file($this->app->getBasePath().'middleware.php')) { |
|
177 | + $this->app->middleware->import(include $this->app->getBasePath().'middleware.php'); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | $autoMulti = $this->app->config->get('app.auto_multi_app', false); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | // 监听HttpRun |
191 | 191 | $this->app->event->trigger('HttpRun'); |
192 | 192 | |
193 | - $withRoute = $this->app->config->get('app.with_route', true) ? function () { |
|
193 | + $withRoute = $this->app->config->get('app.with_route', true) ? function() { |
|
194 | 194 | $this->loadRoutes(); |
195 | 195 | } : null; |
196 | 196 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | $routePath = $this->getRoutePath(); |
209 | 209 | |
210 | 210 | if (is_dir($routePath)) { |
211 | - $files = glob($routePath . '*.php'); |
|
211 | + $files = glob($routePath.'*.php'); |
|
212 | 212 | foreach ($files as $file) { |
213 | 213 | include $file; |
214 | 214 | } |
@@ -224,11 +224,11 @@ discard block |
||
224 | 224 | */ |
225 | 225 | protected function getRoutePath(): string |
226 | 226 | { |
227 | - if ($this->isMulti() && is_dir($this->app->getAppPath() . 'route')) { |
|
228 | - return $this->app->getAppPath() . 'route' . DIRECTORY_SEPARATOR; |
|
227 | + if ($this->isMulti() && is_dir($this->app->getAppPath().'route')) { |
|
228 | + return $this->app->getAppPath().'route'.DIRECTORY_SEPARATOR; |
|
229 | 229 | } |
230 | 230 | |
231 | - return $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR . ($this->isMulti() ? $this->getName() . DIRECTORY_SEPARATOR : ''); |
|
231 | + return $this->app->getRootPath().'route'.DIRECTORY_SEPARATOR.($this->isMulti() ? $this->getName().DIRECTORY_SEPARATOR : ''); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | $appName = $map[$name]; |
315 | 315 | } |
316 | 316 | } elseif ($name && (false !== array_search($name, $map) || in_array($name, $deny))) { |
317 | - throw new HttpException(404, 'app not exists:' . $name); |
|
317 | + throw new HttpException(404, 'app not exists:'.$name); |
|
318 | 318 | } elseif ($name && isset($map['*'])) { |
319 | 319 | $appName = $map['*']; |
320 | 320 | } else { |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | } |
323 | 323 | |
324 | 324 | if ($name) { |
325 | - $this->app->request->setRoot('/' . $name); |
|
325 | + $this->app->request->setRoot('/'.$name); |
|
326 | 326 | $this->app->request->setPathinfo(strpos($path, '/') ? ltrim(strstr($path, '/'), '/') : ''); |
327 | 327 | } |
328 | 328 | } |
@@ -342,41 +342,41 @@ discard block |
||
342 | 342 | { |
343 | 343 | $this->name = $appName; |
344 | 344 | $this->app->request->setApp($appName); |
345 | - $this->app->setAppPath($this->path ?: $this->app->getBasePath() . $appName . DIRECTORY_SEPARATOR); |
|
346 | - $this->app->setRuntimePath($this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . $appName . DIRECTORY_SEPARATOR); |
|
345 | + $this->app->setAppPath($this->path ?: $this->app->getBasePath().$appName.DIRECTORY_SEPARATOR); |
|
346 | + $this->app->setRuntimePath($this->app->getRootPath().'runtime'.DIRECTORY_SEPARATOR.$appName.DIRECTORY_SEPARATOR); |
|
347 | 347 | |
348 | 348 | //加载app文件 |
349 | 349 | if (is_dir($this->app->getAppPath())) { |
350 | 350 | $appPath = $this->app->getAppPath(); |
351 | 351 | |
352 | - if (is_file($appPath . 'common.php')) { |
|
353 | - include_once $appPath . 'common.php'; |
|
352 | + if (is_file($appPath.'common.php')) { |
|
353 | + include_once $appPath.'common.php'; |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | $configPath = $this->app->getConfigPath(); |
357 | 357 | |
358 | 358 | $files = []; |
359 | 359 | |
360 | - if (is_dir($configPath . $appName)) { |
|
361 | - $files = array_merge($files, glob($configPath . $appName . DIRECTORY_SEPARATOR . '*' . $this->app->getConfigExt())); |
|
362 | - } elseif (is_dir($appPath . 'config')) { |
|
363 | - $files = array_merge($files, glob($appPath . 'config' . DIRECTORY_SEPARATOR . '*' . $this->app->getConfigExt())); |
|
360 | + if (is_dir($configPath.$appName)) { |
|
361 | + $files = array_merge($files, glob($configPath.$appName.DIRECTORY_SEPARATOR.'*'.$this->app->getConfigExt())); |
|
362 | + } elseif (is_dir($appPath.'config')) { |
|
363 | + $files = array_merge($files, glob($appPath.'config'.DIRECTORY_SEPARATOR.'*'.$this->app->getConfigExt())); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | foreach ($files as $file) { |
367 | 367 | $this->app->config->load($file, pathinfo($file, PATHINFO_FILENAME)); |
368 | 368 | } |
369 | 369 | |
370 | - if (is_file($appPath . 'event.php')) { |
|
371 | - $this->app->loadEvent(include $appPath . 'event.php'); |
|
370 | + if (is_file($appPath.'event.php')) { |
|
371 | + $this->app->loadEvent(include $appPath.'event.php'); |
|
372 | 372 | } |
373 | 373 | |
374 | - if (is_file($appPath . 'middleware.php')) { |
|
375 | - $this->app->middleware->import(include $appPath . 'middleware.php'); |
|
374 | + if (is_file($appPath.'middleware.php')) { |
|
375 | + $this->app->middleware->import(include $appPath.'middleware.php'); |
|
376 | 376 | } |
377 | 377 | |
378 | - if (is_file($appPath . 'provider.php')) { |
|
379 | - $this->app->bind(include $appPath . 'provider.php'); |
|
378 | + if (is_file($appPath.'provider.php')) { |
|
379 | + $this->app->bind(include $appPath.'provider.php'); |
|
380 | 380 | } |
381 | 381 | } |
382 | 382 | |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | $this->app->loadLangPack($this->app->lang->defaultLangSet()); |
385 | 385 | |
386 | 386 | // 设置应用命名空间 |
387 | - $this->app->setNamespace($this->app->config->get('app.app_namespace') ?: 'app\\' . $appName); |
|
387 | + $this->app->setNamespace($this->app->config->get('app.app_namespace') ?: 'app\\'.$appName); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | /** |