@@ -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\model\concern; |
14 | 14 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | public function setRelation(string $name, $value, array $data = []) |
114 | 114 | { |
115 | 115 | // 检测修改器 |
116 | - $method = 'set' . App::parseName($name, 1) . 'Attr'; |
|
116 | + $method = 'set'.App::parseName($name, 1).'Attr'; |
|
117 | 117 | |
118 | 118 | if (method_exists($this, $method)) { |
119 | 119 | $value = $this->$method($value, array_merge($this->data, $data)); |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | $value = $this->getOrigin($key); |
313 | 313 | |
314 | 314 | if (!is_null($value)) { |
315 | - throw new Exception('bind attr has exists:' . $key); |
|
315 | + throw new Exception('bind attr has exists:'.$key); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | $this->set($key, $relation ? $relation->$attr : null); |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | $count = $this->$relation()->relationCount($result, $closure, $aggregate, $field, $name); |
348 | 348 | |
349 | 349 | if (empty($name)) { |
350 | - $name = App::parseName($relation) . '_' . $aggregate; |
|
350 | + $name = App::parseName($relation).'_'.$aggregate; |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | $result->setAttr($name, $count); |
@@ -467,8 +467,8 @@ discard block |
||
467 | 467 | // 记录当前关联信息 |
468 | 468 | $model = $this->parseModel($model); |
469 | 469 | $name = App::parseName(App::classBaseName($model)); |
470 | - $middle = $middle ?: App::parseName($this->name) . '_' . $name; |
|
471 | - $foreignKey = $foreignKey ?: $name . '_id'; |
|
470 | + $middle = $middle ?: App::parseName($this->name).'_'.$name; |
|
471 | + $foreignKey = $foreignKey ?: $name.'_id'; |
|
472 | 472 | $localKey = $localKey ?: $this->getForeignKey($this->name); |
473 | 473 | |
474 | 474 | return new BelongsToMany($this, $model, $middle, $foreignKey, $localKey); |
@@ -495,8 +495,8 @@ discard block |
||
495 | 495 | if (is_array($morph)) { |
496 | 496 | list($morphType, $foreignKey) = $morph; |
497 | 497 | } else { |
498 | - $morphType = $morph . '_type'; |
|
499 | - $foreignKey = $morph . '_id'; |
|
498 | + $morphType = $morph.'_type'; |
|
499 | + $foreignKey = $morph.'_id'; |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | $type = $type ?: get_class($this); |
@@ -527,8 +527,8 @@ discard block |
||
527 | 527 | if (is_array($morph)) { |
528 | 528 | list($morphType, $foreignKey) = $morph; |
529 | 529 | } else { |
530 | - $morphType = $morph . '_type'; |
|
531 | - $foreignKey = $morph . '_id'; |
|
530 | + $morphType = $morph.'_type'; |
|
531 | + $foreignKey = $morph.'_id'; |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | return new MorphMany($this, $model, $foreignKey, $morphType, $type); |
@@ -554,8 +554,8 @@ discard block |
||
554 | 554 | if (is_array($morph)) { |
555 | 555 | list($morphType, $foreignKey) = $morph; |
556 | 556 | } else { |
557 | - $morphType = $morph . '_type'; |
|
558 | - $foreignKey = $morph . '_id'; |
|
557 | + $morphType = $morph.'_type'; |
|
558 | + $foreignKey = $morph.'_id'; |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | return new MorphTo($this, $morphType, $foreignKey, $alias, $relation); |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | $name = App::classBaseName($name); |
592 | 592 | } |
593 | 593 | |
594 | - return App::parseName($name) . '_id'; |
|
594 | + return App::parseName($name).'_id'; |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | /** |
@@ -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 | |
@@ -310,12 +310,12 @@ discard block |
||
310 | 310 | $query = $this->queryInstance; |
311 | 311 | } else { |
312 | 312 | $query = $this->db->buildQuery($this->connection) |
313 | - ->name($this->name . $this->suffix) |
|
313 | + ->name($this->name.$this->suffix) |
|
314 | 314 | ->pk($this->pk); |
315 | 315 | } |
316 | 316 | |
317 | 317 | if (!empty($this->table)) { |
318 | - $query->table($this->table . $this->suffix); |
|
318 | + $query->table($this->table.$this->suffix); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | $query->model($this) |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | $this->field = array_keys(array_merge($this->schema, $this->jsonType)); |
516 | 516 | } else { |
517 | 517 | $query = $this->db(); |
518 | - $table = $this->table ? $this->table . $this->suffix : $query->getTable(); |
|
518 | + $table = $this->table ? $this->table.$this->suffix : $query->getTable(); |
|
519 | 519 | |
520 | 520 | $this->field = $query->getConnection()->getTableFields($table); |
521 | 521 | } |
@@ -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 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | return $this->make($abstract); |
172 | 172 | } |
173 | 173 | |
174 | - throw new ClassNotFoundException('class not exists: ' . $abstract, $abstract); |
|
174 | + throw new ClassNotFoundException('class not exists: '.$abstract, $abstract); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | |
330 | 330 | return call_user_func_array($function, $args); |
331 | 331 | } catch (ReflectionException $e) { |
332 | - throw new Exception('function not exists: ' . $function . '()'); |
|
332 | + throw new Exception('function not exists: '.$function.'()'); |
|
333 | 333 | } |
334 | 334 | } |
335 | 335 | |
@@ -357,12 +357,12 @@ discard block |
||
357 | 357 | } catch (ReflectionException $e) { |
358 | 358 | if (is_array($method)) { |
359 | 359 | $class = is_object($method[0]) ? get_class($method[0]) : $method[0]; |
360 | - $callback = $class . '::' . $method[1]; |
|
360 | + $callback = $class.'::'.$method[1]; |
|
361 | 361 | } else { |
362 | 362 | $callback = $method; |
363 | 363 | } |
364 | 364 | |
365 | - throw new Exception('method not exists: ' . $callback . '()'); |
|
365 | + throw new Exception('method not exists: '.$callback.'()'); |
|
366 | 366 | } |
367 | 367 | } |
368 | 368 | |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | |
429 | 429 | return $object; |
430 | 430 | } catch (ReflectionException $e) { |
431 | - throw new ClassNotFoundException('class not exists: ' . $class, $class); |
|
431 | + throw new ClassNotFoundException('class not exists: '.$class, $class); |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | } elseif ($param->isDefaultValueAvailable()) { |
490 | 490 | $args[] = $param->getDefaultValue(); |
491 | 491 | } else { |
492 | - throw new InvalidArgumentException('method param miss:' . $name); |
|
492 | + throw new InvalidArgumentException('method param miss:'.$name); |
|
493 | 493 | } |
494 | 494 | } |
495 | 495 |
@@ -8,7 +8,7 @@ |
||
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\filesystem\driver; |
14 | 14 |
@@ -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 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | if (!isset($this->config['channels'][$name])) { |
99 | - throw new InvalidArgumentException('Undefined log config:' . $name); |
|
99 | + throw new InvalidArgumentException('Undefined log config:'.$name); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | $this->channel = $name; |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | if (is_string($msg) && !empty($context)) { |
153 | 153 | $replace = []; |
154 | 154 | foreach ($context as $key => $val) { |
155 | - $replace['{' . $key . '}'] = $val; |
|
155 | + $replace['{'.$key.'}'] = $val; |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | $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; |
14 | 14 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | |
102 | 102 | if ($force || !isset($this->instance[$name])) { |
103 | 103 | if (!isset($this->config['connections'][$name])) { |
104 | - throw new InvalidArgumentException('Undefined db config:' . $name); |
|
104 | + throw new InvalidArgumentException('Undefined db config:'.$name); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | $config = $this->config['connections'][$name]; |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | public function event(string $event, callable $callback): void |
219 | 219 | { |
220 | 220 | if ($this->event) { |
221 | - $this->event->listen('db.' . $event, $callback); |
|
221 | + $this->event->listen('db.'.$event, $callback); |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | public function trigger(string $event, $params = null, bool $once = false) |
234 | 234 | { |
235 | 235 | if ($this->event) { |
236 | - return $this->event->trigger('db.' . $event, $params, $once); |
|
236 | + return $this->event->trigger('db.'.$event, $params, $once); |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 |
@@ -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 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | if ($force || !isset($this->instance[$name])) { |
81 | 81 | if (!isset($this->config['stores'][$name])) { |
82 | - throw new InvalidArgumentException('Undefined cache config:' . $name); |
|
82 | + throw new InvalidArgumentException('Undefined cache config:'.$name); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | $options = $this->config['stores'][$name]; |
@@ -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,7 +186,7 @@ discard block |
||
186 | 186 | // 监听HttpRun |
187 | 187 | $this->app->event->trigger('HttpRun'); |
188 | 188 | |
189 | - $withRoute = $this->app->config->get('app.with_route', true) ? function () { |
|
189 | + $withRoute = $this->app->config->get('app.with_route', true) ? function() { |
|
190 | 190 | $this->loadRoutes(); |
191 | 191 | } : null; |
192 | 192 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | { |
203 | 203 | // 加载路由定义 |
204 | 204 | if (is_dir($this->getRoutePath())) { |
205 | - $files = glob($this->getRoutePath() . '*.php'); |
|
205 | + $files = glob($this->getRoutePath().'*.php'); |
|
206 | 206 | foreach ($files as $file) { |
207 | 207 | include $file; |
208 | 208 | } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | */ |
219 | 219 | protected function getRoutePath(): string |
220 | 220 | { |
221 | - return $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR . ($this->isMulti() ? $this->getName() . DIRECTORY_SEPARATOR : ''); |
|
221 | + return $this->app->getRootPath().'route'.DIRECTORY_SEPARATOR.($this->isMulti() ? $this->getName().DIRECTORY_SEPARATOR : ''); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | $appName = $map[$name]; |
304 | 304 | } |
305 | 305 | } elseif ($name && (false !== array_search($name, $map) || in_array($name, $deny))) { |
306 | - throw new HttpException(404, 'app not exists:' . $name); |
|
306 | + throw new HttpException(404, 'app not exists:'.$name); |
|
307 | 307 | } elseif ($name && isset($map['*'])) { |
308 | 308 | $appName = $map['*']; |
309 | 309 | } else { |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | } |
312 | 312 | |
313 | 313 | if ($name) { |
314 | - $this->app->request->setRoot('/' . $name); |
|
314 | + $this->app->request->setRoot('/'.$name); |
|
315 | 315 | $this->app->request->setPathinfo(strpos($path, '/') ? ltrim(strstr($path, '/'), '/') : ''); |
316 | 316 | } |
317 | 317 | } |
@@ -331,41 +331,41 @@ discard block |
||
331 | 331 | { |
332 | 332 | $this->name = $appName; |
333 | 333 | $this->app->request->setApp($appName); |
334 | - $this->app->setAppPath($this->path ?: $this->app->getBasePath() . $appName . DIRECTORY_SEPARATOR); |
|
335 | - $this->app->setRuntimePath($this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . $appName . DIRECTORY_SEPARATOR); |
|
334 | + $this->app->setAppPath($this->path ?: $this->app->getBasePath().$appName.DIRECTORY_SEPARATOR); |
|
335 | + $this->app->setRuntimePath($this->app->getRootPath().'runtime'.DIRECTORY_SEPARATOR.$appName.DIRECTORY_SEPARATOR); |
|
336 | 336 | |
337 | 337 | //加载app文件 |
338 | 338 | if (is_dir($this->app->getAppPath())) { |
339 | 339 | $appPath = $this->app->getAppPath(); |
340 | 340 | |
341 | - if (is_file($appPath . 'common.php')) { |
|
342 | - include_once $appPath . 'common.php'; |
|
341 | + if (is_file($appPath.'common.php')) { |
|
342 | + include_once $appPath.'common.php'; |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | $configPath = $this->app->getConfigPath(); |
346 | 346 | |
347 | 347 | $files = []; |
348 | 348 | |
349 | - if (is_dir($configPath . $appName)) { |
|
350 | - $files = array_merge($files, glob($configPath . $appName . DIRECTORY_SEPARATOR . '*' . $this->app->getConfigExt())); |
|
351 | - } elseif (is_dir($appPath . 'config')) { |
|
352 | - $files = array_merge($files, glob($appPath . 'config' . DIRECTORY_SEPARATOR . '*' . $this->app->getConfigExt())); |
|
349 | + if (is_dir($configPath.$appName)) { |
|
350 | + $files = array_merge($files, glob($configPath.$appName.DIRECTORY_SEPARATOR.'*'.$this->app->getConfigExt())); |
|
351 | + } elseif (is_dir($appPath.'config')) { |
|
352 | + $files = array_merge($files, glob($appPath.'config'.DIRECTORY_SEPARATOR.'*'.$this->app->getConfigExt())); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | foreach ($files as $file) { |
356 | 356 | $this->app->config->load($file, pathinfo($file, PATHINFO_FILENAME)); |
357 | 357 | } |
358 | 358 | |
359 | - if (is_file($appPath . 'event.php')) { |
|
360 | - $this->app->loadEvent(include $appPath . 'event.php'); |
|
359 | + if (is_file($appPath.'event.php')) { |
|
360 | + $this->app->loadEvent(include $appPath.'event.php'); |
|
361 | 361 | } |
362 | 362 | |
363 | - if (is_file($appPath . 'middleware.php')) { |
|
364 | - $this->app->middleware->import(include $appPath . 'middleware.php'); |
|
363 | + if (is_file($appPath.'middleware.php')) { |
|
364 | + $this->app->middleware->import(include $appPath.'middleware.php'); |
|
365 | 365 | } |
366 | 366 | |
367 | - if (is_file($appPath . 'provider.php')) { |
|
368 | - $this->app->bind(include $appPath . 'provider.php'); |
|
367 | + if (is_file($appPath.'provider.php')) { |
|
368 | + $this->app->bind(include $appPath.'provider.php'); |
|
369 | 369 | } |
370 | 370 | } |
371 | 371 | |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | $this->app->loadLangPack($this->app->lang->defaultLangSet()); |
374 | 374 | |
375 | 375 | // 设置应用命名空间 |
376 | - $this->app->setNamespace($this->app->config->get('app.app_namespace') ?: 'app\\' . $appName); |
|
376 | + $this->app->setNamespace($this->app->config->get('app.app_namespace') ?: 'app\\'.$appName); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | /** |
@@ -29,14 +29,14 @@ discard block |
||
29 | 29 | { |
30 | 30 | $app = $input->getArgument('app'); |
31 | 31 | |
32 | - if (empty($app) && !is_dir($this->app->getBasePath() . 'controller')) { |
|
32 | + if (empty($app) && !is_dir($this->app->getBasePath().'controller')) { |
|
33 | 33 | $output->writeln('<error>Miss app name!</error>'); |
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 .= '\think\App::unserialize(\'' . \think\App::serialize($this->app->route->getName()) . '\');'; |
|
67 | + $content = '<?php '.PHP_EOL.'return '; |
|
68 | + $content .= '\think\App::unserialize(\''.\think\App::serialize($this->app->route->getName()).'\');'; |
|
69 | 69 | return $content; |
70 | 70 | } |
71 | 71 |