@@ -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 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | if (strpos($controller, '.')) { |
| 55 | 55 | $pos = strrpos($controller, '.'); |
| 56 | - $this->controller = substr($controller, 0, $pos) . '.' . Str::studly(substr($controller, $pos + 1)); |
|
| 56 | + $this->controller = substr($controller, 0, $pos).'.'.Str::studly(substr($controller, $pos + 1)); |
|
| 57 | 57 | } else { |
| 58 | 58 | $this->controller = Str::studly($controller); |
| 59 | 59 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | // 实例化控制器 |
| 74 | 74 | $instance = $this->controller($this->controller); |
| 75 | 75 | } catch (ClassNotFoundException $e) { |
| 76 | - throw new HttpException(404, 'controller not exists:' . $e->getClass()); |
|
| 76 | + throw new HttpException(404, 'controller not exists:'.$e->getClass()); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | // 注册控制器中间件 |
@@ -81,10 +81,10 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | return $this->app->middleware->pipeline('controller') |
| 83 | 83 | ->send($this->request) |
| 84 | - ->then(function () use ($instance) { |
|
| 84 | + ->then(function() use ($instance) { |
|
| 85 | 85 | // 获取当前操作名 |
| 86 | 86 | $suffix = $this->rule->config('action_suffix'); |
| 87 | - $action = $this->actionName . $suffix; |
|
| 87 | + $action = $this->actionName.$suffix; |
|
| 88 | 88 | |
| 89 | 89 | if (is_callable([$instance, $action])) { |
| 90 | 90 | $vars = $this->request->param(); |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | } else { |
| 106 | 106 | // 操作不存在 |
| 107 | - throw new HttpException(404, 'method not exists:' . get_class($instance) . '->' . $action . '()'); |
|
| 107 | + throw new HttpException(404, 'method not exists:'.get_class($instance).'->'.$action.'()'); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | $data = $this->app->invokeReflectMethod($instance, $reflect, $vars); |
@@ -131,11 +131,11 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | foreach ($middlewares as $key => $val) { |
| 133 | 133 | if (!is_int($key)) { |
| 134 | - if (isset($val['only']) && !in_array($this->request->action(true), array_map(function ($item) { |
|
| 134 | + if (isset($val['only']) && !in_array($this->request->action(true), array_map(function($item) { |
|
| 135 | 135 | return strtolower($item); |
| 136 | 136 | }, is_string($val['only']) ? explode(",", $val['only']) : $val['only']))) { |
| 137 | 137 | continue; |
| 138 | - } elseif (isset($val['except']) && in_array($this->request->action(true), array_map(function ($item) { |
|
| 138 | + } elseif (isset($val['except']) && in_array($this->request->action(true), array_map(function($item) { |
|
| 139 | 139 | return strtolower($item); |
| 140 | 140 | }, is_string($val['except']) ? explode(',', $val['except']) : $val['except']))) { |
| 141 | 141 | continue; |
@@ -167,14 +167,14 @@ discard block |
||
| 167 | 167 | $controllerLayer = $this->rule->config('controller_layer') ?: 'controller'; |
| 168 | 168 | $emptyController = $this->rule->config('empty_controller') ?: 'Error'; |
| 169 | 169 | |
| 170 | - $class = $this->app->parseClass($controllerLayer, $name . $suffix); |
|
| 170 | + $class = $this->app->parseClass($controllerLayer, $name.$suffix); |
|
| 171 | 171 | |
| 172 | 172 | if (class_exists($class)) { |
| 173 | 173 | return $this->app->make($class, [], true); |
| 174 | - } elseif ($emptyController && class_exists($emptyClass = $this->app->parseClass($controllerLayer, $emptyController . $suffix))) { |
|
| 174 | + } elseif ($emptyController && class_exists($emptyClass = $this->app->parseClass($controllerLayer, $emptyController.$suffix))) { |
|
| 175 | 175 | return $this->app->make($emptyClass, [], true); |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - throw new ClassNotFoundException('class not exists:' . $class, $class); |
|
| 178 | + throw new ClassNotFoundException('class not exists:'.$class, $class); |
|
| 179 | 179 | } |
| 180 | 180 | } |