@@ -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 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | public function __construct(App $app) |
57 | 57 | { |
58 | 58 | $this->app = $app; |
59 | - $this->multi = is_dir($this->app->getBasePath() . 'controller') ? false : true; |
|
59 | + $this->multi = is_dir($this->app->getBasePath().'controller') ? false : true; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | $this->initialize(); |
173 | 173 | |
174 | 174 | // 加载全局中间件 |
175 | - if (is_file($this->app->getBasePath() . 'middleware.php')) { |
|
176 | - $this->app->middleware->import(include $this->app->getBasePath() . 'middleware.php'); |
|
175 | + if (is_file($this->app->getBasePath().'middleware.php')) { |
|
176 | + $this->app->middleware->import(include $this->app->getBasePath().'middleware.php'); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | if ($this->multi) { |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | // 监听HttpRun |
187 | 187 | $this->app->event->trigger('HttpRun'); |
188 | 188 | |
189 | - $this->app->log->info($request->ip() . ' ' . $request->method() . ' ' . $request->host() . $request->url()); |
|
189 | + $this->app->log->info($request->ip().' '.$request->method().' '.$request->host().$request->url()); |
|
190 | 190 | |
191 | - $withRoute = $this->app->config->get('app.with_route', true) ? function () { |
|
191 | + $withRoute = $this->app->config->get('app.with_route', true) ? function() { |
|
192 | 192 | $this->loadRoutes(); |
193 | 193 | } : null; |
194 | 194 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | { |
205 | 205 | // 加载路由定义 |
206 | 206 | if (is_dir($this->getRoutePath())) { |
207 | - $files = glob($this->getRoutePath() . '*.php'); |
|
207 | + $files = glob($this->getRoutePath().'*.php'); |
|
208 | 208 | foreach ($files as $file) { |
209 | 209 | include $file; |
210 | 210 | } |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | */ |
221 | 221 | protected function getRoutePath(): string |
222 | 222 | { |
223 | - return $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR . ($this->isMulti() ? $this->getName() . DIRECTORY_SEPARATOR : ''); |
|
223 | + return $this->app->getRootPath().'route'.DIRECTORY_SEPARATOR.($this->isMulti() ? $this->getName().DIRECTORY_SEPARATOR : ''); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | $appName = $map[$name]; |
306 | 306 | } |
307 | 307 | } elseif ($name && (false !== array_search($name, $map) || in_array($name, $deny))) { |
308 | - throw new HttpException(404, 'app not exists:' . $name); |
|
308 | + throw new HttpException(404, 'app not exists:'.$name); |
|
309 | 309 | } elseif ($name && isset($map['*'])) { |
310 | 310 | $appName = $map['*']; |
311 | 311 | } else { |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | } |
314 | 314 | |
315 | 315 | if ($name) { |
316 | - $this->app->request->setRoot('/' . $name); |
|
316 | + $this->app->request->setRoot('/'.$name); |
|
317 | 317 | $this->app->request->setPathinfo(strpos($path, '/') ? ltrim(strstr($path, '/'), '/') : ''); |
318 | 318 | } |
319 | 319 | } |
@@ -333,41 +333,41 @@ discard block |
||
333 | 333 | { |
334 | 334 | $this->name = $appName; |
335 | 335 | $this->app->request->setApp($appName); |
336 | - $this->app->setAppPath($this->path ?: $this->app->getBasePath() . $appName . DIRECTORY_SEPARATOR); |
|
337 | - $this->app->setRuntimePath($this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . $appName . DIRECTORY_SEPARATOR); |
|
336 | + $this->app->setAppPath($this->path ?: $this->app->getBasePath().$appName.DIRECTORY_SEPARATOR); |
|
337 | + $this->app->setRuntimePath($this->app->getRootPath().'runtime'.DIRECTORY_SEPARATOR.$appName.DIRECTORY_SEPARATOR); |
|
338 | 338 | |
339 | 339 | //加载app文件 |
340 | 340 | if (is_dir($this->app->getAppPath())) { |
341 | 341 | $appPath = $this->app->getAppPath(); |
342 | 342 | |
343 | - if (is_file($appPath . 'common.php')) { |
|
344 | - include_once $appPath . 'common.php'; |
|
343 | + if (is_file($appPath.'common.php')) { |
|
344 | + include_once $appPath.'common.php'; |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | $configPath = $this->app->getConfigPath(); |
348 | 348 | |
349 | 349 | $files = []; |
350 | 350 | |
351 | - if (is_dir($configPath . $appName)) { |
|
352 | - $files = array_merge($files, glob($configPath . $appName . DIRECTORY_SEPARATOR . '*' . $this->app->getConfigExt())); |
|
353 | - } elseif (is_dir($appPath . 'config')) { |
|
354 | - $files = array_merge($files, glob($appPath . 'config' . DIRECTORY_SEPARATOR . '*' . $this->app->getConfigExt())); |
|
351 | + if (is_dir($configPath.$appName)) { |
|
352 | + $files = array_merge($files, glob($configPath.$appName.DIRECTORY_SEPARATOR.'*'.$this->app->getConfigExt())); |
|
353 | + } elseif (is_dir($appPath.'config')) { |
|
354 | + $files = array_merge($files, glob($appPath.'config'.DIRECTORY_SEPARATOR.'*'.$this->app->getConfigExt())); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | foreach ($files as $file) { |
358 | 358 | $this->app->config->load($file, pathinfo($file, PATHINFO_FILENAME)); |
359 | 359 | } |
360 | 360 | |
361 | - if (is_file($appPath . 'event.php')) { |
|
362 | - $this->app->loadEvent(include $appPath . 'event.php'); |
|
361 | + if (is_file($appPath.'event.php')) { |
|
362 | + $this->app->loadEvent(include $appPath.'event.php'); |
|
363 | 363 | } |
364 | 364 | |
365 | - if (is_file($appPath . 'middleware.php')) { |
|
366 | - $this->app->middleware->import(include $appPath . 'middleware.php'); |
|
365 | + if (is_file($appPath.'middleware.php')) { |
|
366 | + $this->app->middleware->import(include $appPath.'middleware.php'); |
|
367 | 367 | } |
368 | 368 | |
369 | - if (is_file($appPath . 'provider.php')) { |
|
370 | - $this->app->bind(include $appPath . 'provider.php'); |
|
369 | + if (is_file($appPath.'provider.php')) { |
|
370 | + $this->app->bind(include $appPath.'provider.php'); |
|
371 | 371 | } |
372 | 372 | } |
373 | 373 | |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | $this->app->loadLangPack($this->app->lang->defaultLangSet()); |
376 | 376 | |
377 | 377 | // 设置应用命名空间 |
378 | - $this->app->setNamespace($this->app->config->get('app.app_namespace') ?: 'app\\' . $appName); |
|
378 | + $this->app->setNamespace($this->app->config->get('app.app_namespace') ?: 'app\\'.$appName); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | /** |
@@ -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\log\driver; |
14 | 14 | |
@@ -86,8 +86,7 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | $message[] = $this->config['json'] ? |
89 | - json_encode(['time' => $time, 'type' => $type, 'msg' => $msg], $this->config['json_options']) : |
|
90 | - sprintf($this->config['format'], $time, $type, $msg); |
|
89 | + json_encode(['time' => $time, 'type' => $type, 'msg' => $msg], $this->config['json_options']) : sprintf($this->config['format'], $time, $type, $msg); |
|
91 | 90 | } |
92 | 91 | |
93 | 92 | if (true === $this->config['apart_level'] || in_array($type, $this->config['apart_level'])) { |
@@ -125,7 +124,7 @@ discard block |
||
125 | 124 | $info[$type] = is_array($msg) ? implode(PHP_EOL, $msg) : $msg; |
126 | 125 | } |
127 | 126 | |
128 | - $message = implode(PHP_EOL, $info) . PHP_EOL; |
|
127 | + $message = implode(PHP_EOL, $info).PHP_EOL; |
|
129 | 128 | |
130 | 129 | return error_log($message, 3, $destination); |
131 | 130 | } |
@@ -138,13 +137,13 @@ discard block |
||
138 | 137 | protected function getMasterLogFile(): string |
139 | 138 | { |
140 | 139 | if (empty($this->config['path'])) { |
141 | - $this->config['path'] = $this->app->getRuntimePath() . 'log' . DIRECTORY_SEPARATOR; |
|
140 | + $this->config['path'] = $this->app->getRuntimePath().'log'.DIRECTORY_SEPARATOR; |
|
142 | 141 | } elseif (substr($this->config['path'], -1) != DIRECTORY_SEPARATOR) { |
143 | 142 | $this->config['path'] .= DIRECTORY_SEPARATOR; |
144 | 143 | } |
145 | 144 | |
146 | 145 | if ($this->config['max_files']) { |
147 | - $files = glob($this->config['path'] . '*.log'); |
|
146 | + $files = glob($this->config['path'].'*.log'); |
|
148 | 147 | |
149 | 148 | try { |
150 | 149 | if (count($files) > $this->config['max_files']) { |
@@ -158,17 +157,17 @@ discard block |
||
158 | 157 | if ($this->config['single']) { |
159 | 158 | $name = is_string($this->config['single']) ? $this->config['single'] : 'single'; |
160 | 159 | $cli = $this->isCli ? '_cli' : ''; |
161 | - $destination = $this->config['path'] . $name . $cli . '.log'; |
|
160 | + $destination = $this->config['path'].$name.$cli.'.log'; |
|
162 | 161 | } else { |
163 | 162 | $cli = $this->isCli ? '_cli' : ''; |
164 | 163 | |
165 | 164 | if ($this->config['max_files']) { |
166 | - $filename = date('Ymd') . $cli . '.log'; |
|
165 | + $filename = date('Ymd').$cli.'.log'; |
|
167 | 166 | } else { |
168 | - $filename = date('Ym') . DIRECTORY_SEPARATOR . date('d') . $cli . '.log'; |
|
167 | + $filename = date('Ym').DIRECTORY_SEPARATOR.date('d').$cli.'.log'; |
|
169 | 168 | } |
170 | 169 | |
171 | - $destination = $this->config['path'] . $filename; |
|
170 | + $destination = $this->config['path'].$filename; |
|
172 | 171 | } |
173 | 172 | |
174 | 173 | return $destination; |
@@ -188,14 +187,14 @@ discard block |
||
188 | 187 | if ($this->config['single']) { |
189 | 188 | $name = is_string($this->config['single']) ? $this->config['single'] : 'single'; |
190 | 189 | |
191 | - $name .= '_' . $type; |
|
190 | + $name .= '_'.$type; |
|
192 | 191 | } elseif ($this->config['max_files']) { |
193 | - $name = date('Ymd') . '_' . $type . $cli; |
|
192 | + $name = date('Ymd').'_'.$type.$cli; |
|
194 | 193 | } else { |
195 | - $name = date('d') . '_' . $type . $cli; |
|
194 | + $name = date('d').'_'.$type.$cli; |
|
196 | 195 | } |
197 | 196 | |
198 | - return $path . DIRECTORY_SEPARATOR . $name . '.log'; |
|
197 | + return $path.DIRECTORY_SEPARATOR.$name.'.log'; |
|
199 | 198 | } |
200 | 199 | |
201 | 200 | /** |
@@ -208,7 +207,7 @@ discard block |
||
208 | 207 | { |
209 | 208 | if (is_file($destination) && floor($this->config['file_size']) <= filesize($destination)) { |
210 | 209 | try { |
211 | - rename($destination, dirname($destination) . DIRECTORY_SEPARATOR . time() . '-' . basename($destination)); |
|
210 | + rename($destination, dirname($destination).DIRECTORY_SEPARATOR.time().'-'.basename($destination)); |
|
212 | 211 | } catch (\Exception $e) { |
213 | 212 | // |
214 | 213 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | // +---------------------------------------------------------------------- |
7 | 7 | // | Author: zhangyajun <[email protected]> |
8 | 8 | // +---------------------------------------------------------------------- |
9 | -declare (strict_types = 1); |
|
9 | +declare(strict_types=1); |
|
10 | 10 | |
11 | 11 | namespace think; |
12 | 12 | |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | |
265 | 265 | $command = $this->find($name); |
266 | 266 | |
267 | - $this->app->log->info('run: php think ' . $input); |
|
267 | + $this->app->log->info('run: php think '.$input); |
|
268 | 268 | |
269 | 269 | return $this->doRunCommand($command, $input, $output); |
270 | 270 | } |
@@ -469,10 +469,10 @@ discard block |
||
469 | 469 | public function findNamespace(string $namespace): string |
470 | 470 | { |
471 | 471 | $allNamespaces = $this->getNamespaces(); |
472 | - $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { |
|
473 | - return preg_quote($matches[1]) . '[^:]*'; |
|
472 | + $expr = preg_replace_callback('{([^:]+|)}', function($matches) { |
|
473 | + return preg_quote($matches[1]).'[^:]*'; |
|
474 | 474 | }, $namespace); |
475 | - $namespaces = preg_grep('{^' . $expr . '}', $allNamespaces); |
|
475 | + $namespaces = preg_grep('{^'.$expr.'}', $allNamespaces); |
|
476 | 476 | |
477 | 477 | if (empty($namespaces)) { |
478 | 478 | $message = sprintf('There are no commands defined in the "%s" namespace.', $namespace); |
@@ -509,13 +509,13 @@ discard block |
||
509 | 509 | { |
510 | 510 | $allCommands = array_keys($this->commands); |
511 | 511 | |
512 | - $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { |
|
513 | - return preg_quote($matches[1]) . '[^:]*'; |
|
512 | + $expr = preg_replace_callback('{([^:]+|)}', function($matches) { |
|
513 | + return preg_quote($matches[1]).'[^:]*'; |
|
514 | 514 | }, $name); |
515 | 515 | |
516 | - $commands = preg_grep('{^' . $expr . '}', $allCommands); |
|
516 | + $commands = preg_grep('{^'.$expr.'}', $allCommands); |
|
517 | 517 | |
518 | - if (empty($commands) || count(preg_grep('{^' . $expr . '$}', $commands)) < 1) { |
|
518 | + if (empty($commands) || count(preg_grep('{^'.$expr.'$}', $commands)) < 1) { |
|
519 | 519 | if (false !== $pos = strrpos($name, ':')) { |
520 | 520 | $this->findNamespace(substr($name, 0, $pos)); |
521 | 521 | } |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | } |
710 | 710 | } |
711 | 711 | |
712 | - $alternatives = array_filter($alternatives, function ($lev) use ($threshold) { |
|
712 | + $alternatives = array_filter($alternatives, function($lev) use ($threshold) { |
|
713 | 713 | return $lev < 2 * $threshold; |
714 | 714 | }); |
715 | 715 | asort($alternatives); |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | |
731 | 731 | foreach ($parts as $part) { |
732 | 732 | if (count($namespaces)) { |
733 | - $namespaces[] = end($namespaces) . ':' . $part; |
|
733 | + $namespaces[] = end($namespaces).':'.$part; |
|
734 | 734 | } else { |
735 | 735 | $namespaces[] = $part; |
736 | 736 | } |
@@ -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 | |
@@ -77,14 +77,14 @@ discard block |
||
77 | 77 | |
78 | 78 | // 模板不存在 抛出异常 |
79 | 79 | if (!is_file($template)) { |
80 | - throw new TemplateNotFoundException('template not exists:' . $template, $template); |
|
80 | + throw new TemplateNotFoundException('template not exists:'.$template, $template); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | $this->template = $template; |
84 | 84 | |
85 | 85 | // 记录视图信息 |
86 | 86 | $this->app->log |
87 | - ->record('[ VIEW ] ' . $template . ' [ ' . var_export(array_keys($data), true) . ' ]'); |
|
87 | + ->record('[ VIEW ] '.$template.' [ '.var_export(array_keys($data), true).' ]'); |
|
88 | 88 | |
89 | 89 | extract($data, EXTR_OVERWRITE); |
90 | 90 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $this->content = $content; |
104 | 104 | |
105 | 105 | extract($data, EXTR_OVERWRITE); |
106 | - eval('?>' . $this->content); |
|
106 | + eval('?>'.$this->content); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | private function parseTemplate(string $template): string |
116 | 116 | { |
117 | 117 | if (empty($this->config['view_base'])) { |
118 | - $this->config['view_base'] = $this->app->getRootPath() . 'view' . DIRECTORY_SEPARATOR; |
|
118 | + $this->config['view_base'] = $this->app->getRootPath().'view'.DIRECTORY_SEPARATOR; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | $request = $this->app->request; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | } else { |
132 | 132 | $app = isset($app) ? $app : $request->app(); |
133 | 133 | // 基础视图目录 |
134 | - $path = $this->config['view_base'] . ($app ? $app . DIRECTORY_SEPARATOR : ''); |
|
134 | + $path = $this->config['view_base'].($app ? $app.DIRECTORY_SEPARATOR : ''); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | $depr = $this->config['view_depr']; |
@@ -151,16 +151,16 @@ discard block |
||
151 | 151 | $template = App::parseName($request->action()); |
152 | 152 | } |
153 | 153 | |
154 | - $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template; |
|
154 | + $template = str_replace('.', DIRECTORY_SEPARATOR, $controller).$depr.$template; |
|
155 | 155 | } elseif (false === strpos($template, $depr)) { |
156 | - $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template; |
|
156 | + $template = str_replace('.', DIRECTORY_SEPARATOR, $controller).$depr.$template; |
|
157 | 157 | } |
158 | 158 | } |
159 | 159 | } else { |
160 | 160 | $template = str_replace(['/', ':'], $depr, substr($template, 1)); |
161 | 161 | } |
162 | 162 | |
163 | - return $path . ltrim($template, '/') . '.' . ltrim($this->config['view_suffix'], '.'); |
|
163 | + return $path.ltrim($template, '/').'.'.ltrim($this->config['view_suffix'], '.'); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -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 | |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function __construct(string $rootPath = '') |
110 | 110 | { |
111 | - $this->thinkPath = dirname(__DIR__) . DIRECTORY_SEPARATOR; |
|
112 | - $this->rootPath = $rootPath ? rtrim($rootPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR : $this->getDefaultRootPath(); |
|
113 | - $this->appPath = $this->rootPath . 'app' . DIRECTORY_SEPARATOR; |
|
114 | - $this->runtimePath = $this->rootPath . 'runtime' . DIRECTORY_SEPARATOR; |
|
111 | + $this->thinkPath = dirname(__DIR__).DIRECTORY_SEPARATOR; |
|
112 | + $this->rootPath = $rootPath ? rtrim($rootPath, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR : $this->getDefaultRootPath(); |
|
113 | + $this->appPath = $this->rootPath.'app'.DIRECTORY_SEPARATOR; |
|
114 | + $this->runtimePath = $this->rootPath.'runtime'.DIRECTORY_SEPARATOR; |
|
115 | 115 | |
116 | - if (is_file($this->appPath . 'provider.php')) { |
|
117 | - $this->bind(include $this->appPath . 'provider.php'); |
|
116 | + if (is_file($this->appPath.'provider.php')) { |
|
117 | + $this->bind(include $this->appPath.'provider.php'); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | static::setInstance($this); |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | public function getService($service) |
175 | 175 | { |
176 | 176 | $name = is_string($service) ? $service : get_class($service); |
177 | - return array_values(array_filter($this->services, function ($value) use ($name) { |
|
177 | + return array_values(array_filter($this->services, function($value) use ($name) { |
|
178 | 178 | return $value instanceof $name; |
179 | 179 | }, ARRAY_FILTER_USE_BOTH))[0] ?? null; |
180 | 180 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | */ |
251 | 251 | public function getBasePath(): string |
252 | 252 | { |
253 | - return $this->rootPath . 'app' . DIRECTORY_SEPARATOR; |
|
253 | + return $this->rootPath.'app'.DIRECTORY_SEPARATOR; |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | */ |
309 | 309 | public function getConfigPath(): string |
310 | 310 | { |
311 | - return $this->rootPath . 'config' . DIRECTORY_SEPARATOR; |
|
311 | + return $this->rootPath.'config'.DIRECTORY_SEPARATOR; |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | /** |
@@ -354,8 +354,8 @@ discard block |
||
354 | 354 | $this->beginMem = memory_get_usage(); |
355 | 355 | |
356 | 356 | // 加载环境变量 |
357 | - if (is_file($this->rootPath . '.env')) { |
|
358 | - $this->env->load($this->rootPath . '.env'); |
|
357 | + if (is_file($this->rootPath.'.env')) { |
|
358 | + $this->env->load($this->rootPath.'.env'); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | $this->configExt = $this->env->get('config_ext', '.php'); |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | // 加载框架默认语言包 |
369 | 369 | $langSet = $this->lang->defaultLangSet(); |
370 | 370 | |
371 | - $this->lang->load($this->thinkPath . 'lang' . DIRECTORY_SEPARATOR . $langSet . '.php'); |
|
371 | + $this->lang->load($this->thinkPath.'lang'.DIRECTORY_SEPARATOR.$langSet.'.php'); |
|
372 | 372 | |
373 | 373 | // 加载应用默认语言包 |
374 | 374 | $this->loadLangPack($langSet); |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | } |
408 | 408 | |
409 | 409 | // 加载系统语言包 |
410 | - $files = glob($this->appPath . 'lang' . DIRECTORY_SEPARATOR . $langset . '.*'); |
|
410 | + $files = glob($this->appPath.'lang'.DIRECTORY_SEPARATOR.$langset.'.*'); |
|
411 | 411 | $this->lang->load($files); |
412 | 412 | |
413 | 413 | // 加载扩展(自定义)语言包 |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | */ |
426 | 426 | public function boot(): void |
427 | 427 | { |
428 | - array_walk($this->services, function ($service) { |
|
428 | + array_walk($this->services, function($service) { |
|
429 | 429 | $this->bootService($service); |
430 | 430 | }); |
431 | 431 | } |
@@ -439,30 +439,30 @@ discard block |
||
439 | 439 | { |
440 | 440 | $appPath = $this->getAppPath(); |
441 | 441 | |
442 | - if (is_file($appPath . 'common.php')) { |
|
443 | - include_once $appPath . 'common.php'; |
|
442 | + if (is_file($appPath.'common.php')) { |
|
443 | + include_once $appPath.'common.php'; |
|
444 | 444 | } |
445 | 445 | |
446 | - include_once $this->thinkPath . 'helper.php'; |
|
446 | + include_once $this->thinkPath.'helper.php'; |
|
447 | 447 | |
448 | 448 | $configPath = $this->getConfigPath(); |
449 | 449 | |
450 | 450 | $files = []; |
451 | 451 | |
452 | 452 | if (is_dir($configPath)) { |
453 | - $files = glob($configPath . '*' . $this->configExt); |
|
453 | + $files = glob($configPath.'*'.$this->configExt); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | foreach ($files as $file) { |
457 | 457 | $this->config->load($file, pathinfo($file, PATHINFO_FILENAME)); |
458 | 458 | } |
459 | 459 | |
460 | - if (is_file($appPath . 'event.php')) { |
|
461 | - $this->loadEvent(include $appPath . 'event.php'); |
|
460 | + if (is_file($appPath.'event.php')) { |
|
461 | + $this->loadEvent(include $appPath.'event.php'); |
|
462 | 462 | } |
463 | 463 | |
464 | - if (is_file($appPath . 'service.php')) { |
|
465 | - $services = include $appPath . 'service.php'; |
|
464 | + if (is_file($appPath.'service.php')) { |
|
465 | + $services = include $appPath.'service.php'; |
|
466 | 466 | foreach ($services as $service) { |
467 | 467 | $this->register($service); |
468 | 468 | } |
@@ -527,9 +527,9 @@ discard block |
||
527 | 527 | $name = str_replace(['/', '.'], '\\', $name); |
528 | 528 | $array = explode('\\', $name); |
529 | 529 | $class = self::parseName(array_pop($array), 1); |
530 | - $path = $array ? implode('\\', $array) . '\\' : ''; |
|
530 | + $path = $array ? implode('\\', $array).'\\' : ''; |
|
531 | 531 | |
532 | - return $this->namespace . '\\' . $layer . '\\' . $path . $class; |
|
532 | + return $this->namespace.'\\'.$layer.'\\'.$path.$class; |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | /** |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | { |
551 | 551 | $path = dirname(dirname(dirname(dirname($this->thinkPath)))); |
552 | 552 | |
553 | - return $path . DIRECTORY_SEPARATOR; |
|
553 | + return $path.DIRECTORY_SEPARATOR; |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | /** |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | public static function parseName(string $name = null, int $type = 0, bool $ucfirst = true): string |
566 | 566 | { |
567 | 567 | if ($type) { |
568 | - $name = preg_replace_callback('/_([a-zA-Z])/', function ($match) { |
|
568 | + $name = preg_replace_callback('/_([a-zA-Z])/', function($match) { |
|
569 | 569 | return strtoupper($match[1]); |
570 | 570 | }, $name); |
571 | 571 | return $ucfirst ? ucfirst($name) : lcfirst($name); |
@@ -596,13 +596,13 @@ discard block |
||
596 | 596 | */ |
597 | 597 | public static function factory(string $name, string $namespace = '', ...$args) |
598 | 598 | { |
599 | - $class = false !== strpos($name, '\\') ? $name : $namespace . ucwords($name); |
|
599 | + $class = false !== strpos($name, '\\') ? $name : $namespace.ucwords($name); |
|
600 | 600 | |
601 | 601 | if (class_exists($class)) { |
602 | 602 | return Container::getInstance()->invokeClass($class, $args); |
603 | 603 | } |
604 | 604 | |
605 | - throw new ClassNotFoundException('class not exists:' . $class, $class); |
|
605 | + throw new ClassNotFoundException('class not exists:'.$class, $class); |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | /** |
@@ -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 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | |
134 | 134 | foreach ($names as $name) { |
135 | 135 | if (!isset($this->config['channels'][$name])) { |
136 | - throw new InvalidArgumentException('Undefined log config:' . $name); |
|
136 | + throw new InvalidArgumentException('Undefined log config:'.$name); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | $config = $this->config['channels'][$name]; |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | if (is_string($msg) && !empty($context)) { |
196 | 196 | $replace = []; |
197 | 197 | foreach ($context as $key => $val) { |
198 | - $replace['{' . $key . '}'] = $val; |
|
198 | + $replace['{'.$key.'}'] = $val; |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | $msg = strtr($msg, $replace); |
@@ -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\db; |
14 | 14 | |
@@ -126,15 +126,15 @@ discard block |
||
126 | 126 | $name = App::parseName(substr($method, 5)); |
127 | 127 | array_unshift($args, $name); |
128 | 128 | return call_user_func_array([$this, 'where'], $args); |
129 | - } elseif ($this->model && method_exists($this->model, 'scope' . $method)) { |
|
129 | + } elseif ($this->model && method_exists($this->model, 'scope'.$method)) { |
|
130 | 130 | // 动态调用命名范围 |
131 | - $method = 'scope' . $method; |
|
131 | + $method = 'scope'.$method; |
|
132 | 132 | array_unshift($args, $this); |
133 | 133 | |
134 | 134 | call_user_func_array([$this->model, $method], $args); |
135 | 135 | return $this; |
136 | 136 | } else { |
137 | - throw new Exception('method not exist:' . static::class . '->' . $method); |
|
137 | + throw new Exception('method not exist:'.static::class.'->'.$method); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | |
209 | 209 | $name = $name ?: $this->name; |
210 | 210 | |
211 | - return $this->prefix . App::parseName($name); |
|
211 | + return $this->prefix.App::parseName($name); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -433,10 +433,10 @@ discard block |
||
433 | 433 | $prefix = $prefix ?: $tableName; |
434 | 434 | foreach ($field as $key => &$val) { |
435 | 435 | if (is_numeric($key) && $alias) { |
436 | - $field[$prefix . '.' . $val] = $alias . $val; |
|
436 | + $field[$prefix.'.'.$val] = $alias.$val; |
|
437 | 437 | unset($field[$key]); |
438 | 438 | } elseif (is_numeric($key)) { |
439 | - $val = $prefix . '.' . $val; |
|
439 | + $val = $prefix.'.'.$val; |
|
440 | 440 | } |
441 | 441 | } |
442 | 442 | |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | // 延迟写入 |
491 | 491 | $condition = $this->options['where'] ?? []; |
492 | 492 | |
493 | - $guid = md5($this->getTable() . '_' . $field . '_' . serialize($condition)); |
|
493 | + $guid = md5($this->getTable().'_'.$field.'_'.serialize($condition)); |
|
494 | 494 | $step = $this->connection->lazyWrite($op, $guid, $step, $lazyTime); |
495 | 495 | |
496 | 496 | if (false === $step) { |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | */ |
559 | 559 | public function limit(int $offset, int $length = null) |
560 | 560 | { |
561 | - $this->options['limit'] = $offset . ($length ? ',' . $length : ''); |
|
561 | + $this->options['limit'] = $offset.($length ? ','.$length : ''); |
|
562 | 562 | |
563 | 563 | return $this; |
564 | 564 | } |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | |
743 | 743 | if (is_string($field)) { |
744 | 744 | if (!empty($this->options['via'])) { |
745 | - $field = $this->options['via'] . '.' . $field; |
|
745 | + $field = $this->options['via'].'.'.$field; |
|
746 | 746 | } |
747 | 747 | if (strpos($field, ',')) { |
748 | 748 | $field = array_map('trim', explode(',', $field)); |
@@ -752,9 +752,9 @@ discard block |
||
752 | 752 | } elseif (!empty($this->options['via'])) { |
753 | 753 | foreach ($field as $key => $val) { |
754 | 754 | if (is_numeric($key)) { |
755 | - $field[$key] = $this->options['via'] . '.' . $val; |
|
755 | + $field[$key] = $this->options['via'].'.'.$val; |
|
756 | 756 | } else { |
757 | - $field[$this->options['via'] . '.' . $key] = $val; |
|
757 | + $field[$this->options['via'].'.'.$key] = $val; |
|
758 | 758 | unset($field[$key]); |
759 | 759 | } |
760 | 760 | } |
@@ -1428,7 +1428,7 @@ discard block |
||
1428 | 1428 | */ |
1429 | 1429 | public function buildSql(bool $sub = true): string |
1430 | 1430 | { |
1431 | - return $sub ? '( ' . $this->fetchSql()->select() . ' )' : $this->fetchSql()->select(); |
|
1431 | + return $sub ? '( '.$this->fetchSql()->select().' )' : $this->fetchSql()->select(); |
|
1432 | 1432 | } |
1433 | 1433 | |
1434 | 1434 | /** |
@@ -1484,7 +1484,7 @@ discard block |
||
1484 | 1484 | $page = $page > 0 ? $page : 1; |
1485 | 1485 | $listRows = $listRows ?: (is_numeric($options['limit']) ? $options['limit'] : 20); |
1486 | 1486 | $offset = $listRows * ($page - 1); |
1487 | - $options['limit'] = $offset . ',' . $listRows; |
|
1487 | + $options['limit'] = $offset.','.$listRows; |
|
1488 | 1488 | } |
1489 | 1489 | |
1490 | 1490 | $this->options = $options; |
@@ -1548,7 +1548,7 @@ discard block |
||
1548 | 1548 | $alias = $this->options['alias'][$table]; |
1549 | 1549 | } |
1550 | 1550 | |
1551 | - $key = isset($alias) ? $alias . '.' . $pk : $pk; |
|
1551 | + $key = isset($alias) ? $alias.'.'.$pk : $pk; |
|
1552 | 1552 | // 根据主键查询 |
1553 | 1553 | if (is_array($data)) { |
1554 | 1554 | $this->where($key, 'in', $data); |