Completed
Push — 6.0 ( 9db11b...892b87 )
by yun
06:42
created
tests/MiddlewareTest.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 
65 65
         $this->middleware->add('foo');
66 66
         $this->assertEquals(4, count($this->middleware->all()));
67
-        $this->middleware->add(function () {
67
+        $this->middleware->add(function() {
68 68
         });
69 69
         $this->assertEquals(5, count($this->middleware->all()));
70 70
     }
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
         $handle->shouldReceive('report')->with($e)->andReturnNull();
84 84
         $handle->shouldReceive('render')->with($request, $e)->andReturn($response);
85 85
 
86
-        $foo->shouldReceive('handle')->once()->andReturnUsing(function ($request, $next) {
86
+        $foo->shouldReceive('handle')->once()->andReturnUsing(function($request, $next) {
87 87
             return $next($request);
88 88
         });
89
-        $bar->shouldReceive('handle')->once()->andReturnUsing(function ($request, $next) use ($e) {
89
+        $bar->shouldReceive('handle')->once()->andReturnUsing(function($request, $next) use ($e) {
90 90
             $next($request);
91 91
             throw  $e;
92 92
         });
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
 
98 98
         $this->config->shouldReceive('get')->once()->with('middleware.priority', [])->andReturn(['FooMiddleware', 'BarMiddleware']);
99 99
 
100
-        $this->middleware->import([function ($request, $next) {
100
+        $this->middleware->import([function($request, $next) {
101 101
             return $next($request);
102 102
         }, 'BarMiddleware', 'FooMiddleware']);
103 103
 
104 104
         $this->assertInstanceOf(Pipeline::class, $pipeline = $this->middleware->pipeline());
105 105
 
106
-        $pipeline->send($request)->then(function ($request) use ($e, $response) {
106
+        $pipeline->send($request)->then(function($request) use ($e, $response) {
107 107
             throw $e;
108 108
         });
109 109
 
Please login to merge, or discard this patch.
src/think/Middleware.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 // +----------------------------------------------------------------------
9 9
 // | Author: Slince <[email protected]>
10 10
 // +----------------------------------------------------------------------
11
-declare (strict_types = 1);
11
+declare(strict_types=1);
12 12
 
13 13
 namespace think;
14 14
 
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
     public function pipeline(string $type = 'route')
118 118
     {
119 119
         return (new Pipeline())
120
-            ->through(array_map(function ($middleware) {
121
-                return function ($request, $next) use ($middleware) {
120
+            ->through(array_map(function($middleware) {
121
+                return function($request, $next) use ($middleware) {
122 122
                     list($call, $param) = $middleware;
123 123
                     if (is_array($call) && is_string($call[0])) {
124 124
                         $call = [$this->app->make($call[0]), $call[1]];
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
     protected function sortMiddleware(array $middlewares)
216 216
     {
217 217
         $priority = $this->app->config->get('middleware.priority', []);
218
-        uasort($middlewares, function ($a, $b) use ($priority) {
218
+        uasort($middlewares, function($a, $b) use ($priority) {
219 219
             $aPriority = $this->getMiddlewarePriority($priority, $a);
220 220
             $bPriority = $this->getMiddlewarePriority($priority, $b);
221 221
             return $bPriority - $aPriority;
Please login to merge, or discard this patch.
src/think/Pipeline.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -54,10 +54,10 @@  discard block
 block discarded – undo
54 54
         $pipeline = array_reduce(
55 55
             array_reverse($this->pipes),
56 56
             $this->carry(),
57
-            function ($passable) use ($destination) {
57
+            function($passable) use ($destination) {
58 58
                 try {
59 59
                     return $destination($passable);
60
-                } catch (Throwable|Exception $e) {
60
+                } catch (Throwable | Exception $e) {
61 61
                     return $this->handleException($passable, $e);
62 62
                 }
63 63
             });
@@ -78,11 +78,11 @@  discard block
 block discarded – undo
78 78
 
79 79
     protected function carry()
80 80
     {
81
-        return function ($stack, $pipe) {
82
-            return function ($passable) use ($stack, $pipe) {
81
+        return function($stack, $pipe) {
82
+            return function($passable) use ($stack, $pipe) {
83 83
                 try {
84 84
                     return $pipe($passable, $stack);
85
-                } catch (Throwable|Exception $e) {
85
+                } catch (Throwable | Exception $e) {
86 86
                     return $this->handleException($passable, $e);
87 87
                 }
88 88
             };
Please login to merge, or discard this patch.
src/think/middleware/LoadLangPack.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
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\middleware;
14 14
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
         if ($this->lang->defaultLangSet() != $langset) {
49 49
             // 加载系统语言包
50 50
             $this->lang->load([
51
-                $this->app->getThinkPath() . 'lang' . DIRECTORY_SEPARATOR . $langset . '.php',
51
+                $this->app->getThinkPath().'lang'.DIRECTORY_SEPARATOR.$langset.'.php',
52 52
             ]);
53 53
 
54 54
             $this->app->LoadLangPack($langset);
Please login to merge, or discard this patch.
src/think/route/dispatch/Controller.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,9 +81,9 @@  discard block
 block discarded – undo
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
-                $action = $this->actionName . $this->rule->config('action_suffix');
86
+                $action = $this->actionName.$this->rule->config('action_suffix');
87 87
 
88 88
                 if (is_callable([$instance, $action])) {
89 89
                     $vars = $this->request->param();
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
                     }
100 100
                 } else {
101 101
                     // 操作不存在
102
-                    throw new HttpException(404, 'method not exists:' . get_class($instance) . '->' . $action . '()');
102
+                    throw new HttpException(404, 'method not exists:'.get_class($instance).'->'.$action.'()');
103 103
                 }
104 104
 
105 105
                 $data = $this->app->invokeReflectMethod($instance, $reflect, $vars);
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
 
127 127
             foreach ($middlewares as $key => $val) {
128 128
                 if (!is_int($key)) {
129
-                    if (isset($val['only']) && !in_array($this->request->action(true), array_map(function ($item) {
129
+                    if (isset($val['only']) && !in_array($this->request->action(true), array_map(function($item) {
130 130
                             return strtolower($item);
131 131
                         }, $val['only']))) {
132 132
                         continue;
133
-                    } elseif (isset($val['except']) && in_array($this->request->action(true), array_map(function ($item) {
133
+                    } elseif (isset($val['except']) && in_array($this->request->action(true), array_map(function($item) {
134 134
                             return strtolower($item);
135 135
                         }, $val['except']))) {
136 136
                         continue;
@@ -158,14 +158,14 @@  discard block
 block discarded – undo
158 158
         $controllerLayer = $this->rule->config('controller_layer') ?: 'controller';
159 159
         $emptyController = $this->rule->config('empty_controller') ?: 'Error';
160 160
 
161
-        $class = $this->app->parseClass($controllerLayer, $name . $suffix);
161
+        $class = $this->app->parseClass($controllerLayer, $name.$suffix);
162 162
 
163 163
         if (class_exists($class)) {
164 164
             return $this->app->make($class, [], true);
165
-        } elseif ($emptyController && class_exists($emptyClass = $this->app->parseClass($controllerLayer, $emptyController . $suffix))) {
165
+        } elseif ($emptyController && class_exists($emptyClass = $this->app->parseClass($controllerLayer, $emptyController.$suffix))) {
166 166
             return $this->app->make($emptyClass, [], true);
167 167
         }
168 168
 
169
-        throw new ClassNotFoundException('class not exists:' . $class, $class);
169
+        throw new ClassNotFoundException('class not exists:'.$class, $class);
170 170
     }
171 171
 }
Please login to merge, or discard this patch.
src/think/Route.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
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
 
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
         $this->ruleName = new RuleName();
171 171
         $this->setDefaultDomain();
172 172
 
173
-        if (is_file($this->app->getRuntimePath() . 'route.php')) {
173
+        if (is_file($this->app->getRuntimePath().'route.php')) {
174 174
             // 读取路由映射文件
175
-            $this->import(include $this->app->getRuntimePath() . 'route.php');
175
+            $this->import(include $this->app->getRuntimePath().'route.php');
176 176
         }
177 177
     }
178 178
 
@@ -401,13 +401,13 @@  discard block
 block discarded – undo
401 401
         if (is_null($domain)) {
402 402
             $domain = $this->host;
403 403
         } elseif (false === strpos($domain, '.')) {
404
-            $domain .= '.' . $this->request->rootDomain();
404
+            $domain .= '.'.$this->request->rootDomain();
405 405
         }
406 406
 
407 407
         $subDomain = $this->request->subDomain();
408 408
 
409 409
         if (strpos($subDomain, '.')) {
410
-            $name = '*' . strstr($subDomain, '.');
410
+            $name = '*'.strstr($subDomain, '.');
411 411
         }
412 412
 
413 413
         if (isset($this->bind[$domain])) {
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
         $this->init();
740 740
 
741 741
         if ($withRoute) {
742
-            $checkCallback = function () use ($request, $withRoute) {
742
+            $checkCallback = function() use ($request, $withRoute) {
743 743
                 //加载路由
744 744
                 $withRoute();
745 745
                 return $this->check();
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 
761 761
         return $this->app->middleware->pipeline()
762 762
             ->send($request)
763
-            ->then(function () use ($dispatch) {
763
+            ->then(function() use ($dispatch) {
764 764
                 return $dispatch->run();
765 765
             });
766 766
     }
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
             $closure  = $this->config['route_check_cache_key'];
778 778
             $routeKey = $closure($request);
779 779
         } else {
780
-            $routeKey = md5($request->baseUrl(true) . ':' . $request->method());
780
+            $routeKey = md5($request->baseUrl(true).':'.$request->method());
781 781
         }
782 782
 
783 783
         return $routeKey;
@@ -827,10 +827,10 @@  discard block
 block discarded – undo
827 827
             $path = $pathinfo;
828 828
         } elseif ($suffix) {
829 829
             // 去除正常的URL后缀
830
-            $path = preg_replace('/\.(' . ltrim($suffix, '.') . ')$/i', '', $pathinfo);
830
+            $path = preg_replace('/\.('.ltrim($suffix, '.').')$/i', '', $pathinfo);
831 831
         } else {
832 832
             // 允许任何后缀访问
833
-            $path = preg_replace('/\.' . $this->request->ext() . '$/i', '', $pathinfo);
833
+            $path = preg_replace('/\.'.$this->request->ext().'$/i', '', $pathinfo);
834 834
         }
835 835
 
836 836
         return $path;
@@ -873,9 +873,9 @@  discard block
 block discarded – undo
873 873
                 $item = $this->domains[$this->host];
874 874
             } elseif (isset($this->domains[$subDomain])) {
875 875
                 $item = $this->domains[$subDomain];
876
-            } elseif (isset($this->domains['*.' . $domain2]) && !empty($domain3)) {
876
+            } elseif (isset($this->domains['*.'.$domain2]) && !empty($domain3)) {
877 877
                 // 泛三级域名
878
-                $item      = $this->domains['*.' . $domain2];
878
+                $item      = $this->domains['*.'.$domain2];
879 879
                 $panDomain = $domain3;
880 880
             } elseif (isset($this->domains['*']) && !empty($domain2)) {
881 881
                 // 泛二级域名
Please login to merge, or discard this patch.
src/think/exception/Handle.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
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\exception;
14 14
 
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
                     'code'    => $this->getCode($exception),
70 70
                     'message' => $this->getMessage($exception),
71 71
                 ];
72
-                $log  = "[{$data['code']}]{$data['message']}";
72
+                $log = "[{$data['code']}]{$data['message']}";
73 73
             }
74 74
 
75 75
             if ($this->app->config->get('log.record_trace')) {
76
-                $log .= PHP_EOL . $exception->getTraceAsString();
76
+                $log .= PHP_EOL.$exception->getTraceAsString();
77 77
             }
78 78
 
79 79
             $this->app->log->record($log, 'error');
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 
207 207
             ob_start();
208 208
             extract($data);
209
-            include $this->app->config->get('app.exception_tmpl') ?: __DIR__ . '/../../tpl/think_exception.tpl';
209
+            include $this->app->config->get('app.exception_tmpl') ?: __DIR__.'/../../tpl/think_exception.tpl';
210 210
 
211 211
             // 获取并清空缓存
212 212
             $data     = ob_get_clean();
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 
261 261
         if (strpos($message, ':')) {
262 262
             $name    = strstr($message, ':', true);
263
-            $message = $lang->has($name) ? $lang->get($name) . strstr($message, ':') : $message;
263
+            $message = $lang->has($name) ? $lang->get($name).strstr($message, ':') : $message;
264 264
         } elseif (strpos($message, ',')) {
265 265
             $name    = strstr($message, ',', true);
266
-            $message = $lang->has($name) ? $lang->get($name) . ':' . substr(strstr($message, ','), 1) : $message;
266
+            $message = $lang->has($name) ? $lang->get($name).':'.substr(strstr($message, ','), 1) : $message;
267 267
         } elseif ($lang->has($message)) {
268 268
             $message = $lang->get($message);
269 269
         }
Please login to merge, or discard this patch.