@@ -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\dispatch; |
14 | 14 | |
@@ -68,15 +68,15 @@ discard block |
||
68 | 68 | // 实例化控制器 |
69 | 69 | $instance = $this->controller($this->controller); |
70 | 70 | } catch (ClassNotFoundException $e) { |
71 | - throw new HttpException(404, 'controller not exists:' . $e->getClass()); |
|
71 | + throw new HttpException(404, 'controller not exists:'.$e->getClass()); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | // 注册控制器中间件 |
75 | 75 | $this->registerControllerMiddleware($instance); |
76 | 76 | |
77 | - $this->app->middleware->controller(function (Request $request, $next) use ($instance) { |
|
77 | + $this->app->middleware->controller(function(Request $request, $next) use ($instance) { |
|
78 | 78 | // 获取当前操作名 |
79 | - $action = $this->actionName . $this->rule->config('action_suffix'); |
|
79 | + $action = $this->actionName.$this->rule->config('action_suffix'); |
|
80 | 80 | |
81 | 81 | if (is_callable([$instance, $action])) { |
82 | 82 | $vars = $this->request->param(); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | } |
93 | 93 | } else { |
94 | 94 | // 操作不存在 |
95 | - throw new HttpException(404, 'method not exists:' . get_class($instance) . '->' . $action . '()'); |
|
95 | + throw new HttpException(404, 'method not exists:'.get_class($instance).'->'.$action.'()'); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | $data = $this->app->invokeReflectMethod($instance, $reflect, $vars); |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | |
122 | 122 | foreach ($middlewares as $key => $val) { |
123 | 123 | if (!is_int($key)) { |
124 | - if (isset($val['only']) && !in_array($this->request->action(true), array_map(function ($item) { |
|
124 | + if (isset($val['only']) && !in_array($this->request->action(true), array_map(function($item) { |
|
125 | 125 | return strtolower($item); |
126 | 126 | }, $val['only']))) { |
127 | 127 | continue; |
128 | - } elseif (isset($val['except']) && in_array($this->request->action(true), array_map(function ($item) { |
|
128 | + } elseif (isset($val['except']) && in_array($this->request->action(true), array_map(function($item) { |
|
129 | 129 | return strtolower($item); |
130 | 130 | }, $val['except']))) { |
131 | 131 | continue; |
@@ -153,14 +153,14 @@ discard block |
||
153 | 153 | $controllerLayer = $this->rule->config('controller_layer') ?: 'controller'; |
154 | 154 | $emptyController = $this->rule->config('empty_controller') ?: 'Error'; |
155 | 155 | |
156 | - $class = $this->app->parseClass($controllerLayer, $name . $suffix); |
|
156 | + $class = $this->app->parseClass($controllerLayer, $name.$suffix); |
|
157 | 157 | |
158 | 158 | if (class_exists($class)) { |
159 | 159 | return $this->app->make($class, [], true); |
160 | - } elseif ($emptyController && class_exists($emptyClass = $this->app->parseClass($controllerLayer, $emptyController . $suffix))) { |
|
160 | + } elseif ($emptyController && class_exists($emptyClass = $this->app->parseClass($controllerLayer, $emptyController.$suffix))) { |
|
161 | 161 | return $this->app->make($emptyClass, [], true); |
162 | 162 | } |
163 | 163 | |
164 | - throw new ClassNotFoundException('class not exists:' . $class, $class); |
|
164 | + throw new ClassNotFoundException('class not exists:'.$class, $class); |
|
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\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 | |
@@ -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 | |
@@ -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]; |
@@ -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 |
@@ -42,15 +42,15 @@ discard block |
||
42 | 42 | { |
43 | 43 | $app = $input->getArgument('app'); |
44 | 44 | |
45 | - if (empty($app) && !is_dir($this->app->getBasePath() . 'controller')) { |
|
45 | + if (empty($app) && !is_dir($this->app->getBasePath().'controller')) { |
|
46 | 46 | $output->writeln('<error>Miss app name!</error>'); |
47 | 47 | return false; |
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; |
14 | 14 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | protected function loadRoutesFrom($path) |
38 | 38 | { |
39 | - $this->registerRoutes(function () use ($path) { |
|
39 | + $this->registerRoutes(function() use ($path) { |
|
40 | 40 | include $path; |
41 | 41 | }); |
42 | 42 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | { |
60 | 60 | $commands = is_array($commands) ? $commands : func_get_args(); |
61 | 61 | |
62 | - Console::starting(function (Console $console) use ($commands) { |
|
62 | + Console::starting(function(Console $console) use ($commands) { |
|
63 | 63 | $console->addCommands($commands); |
64 | 64 | }); |
65 | 65 | } |