Completed
Push — 6.0 ( 09da7f...677f21 )
by liu
06:22
created
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');
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
         ob_start();
214 214
         $data = $this->convertExceptionToArray($exception);
215 215
         extract($data);
216
-        include $this->app->config->get('app.exception_tmpl') ?: __DIR__ . '/../../tpl/think_exception.tpl';
216
+        include $this->app->config->get('app.exception_tmpl') ?: __DIR__.'/../../tpl/think_exception.tpl';
217 217
 
218 218
         return ob_get_clean();
219 219
     }
@@ -255,10 +255,10 @@  discard block
 block discarded – undo
255 255
 
256 256
         if (strpos($message, ':')) {
257 257
             $name    = strstr($message, ':', true);
258
-            $message = $lang->has($name) ? $lang->get($name) . strstr($message, ':') : $message;
258
+            $message = $lang->has($name) ? $lang->get($name).strstr($message, ':') : $message;
259 259
         } elseif (strpos($message, ',')) {
260 260
             $name    = strstr($message, ',', true);
261
-            $message = $lang->has($name) ? $lang->get($name) . ':' . substr(strstr($message, ','), 1) : $message;
261
+            $message = $lang->has($name) ? $lang->get($name).':'.substr(strstr($message, ','), 1) : $message;
262 262
         } elseif ($lang->has($message)) {
263 263
             $message = $lang->get($message);
264 264
         }
Please login to merge, or discard this patch.
src/think/route/Url.php 1 patch
Spacing   +22 added lines, -22 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;
14 14
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
                 }
191 191
             }
192 192
         } elseif (false === strpos($domain, '.') && 0 !== strpos($domain, $rootDomain)) {
193
-            $domain .= '.' . $rootDomain;
193
+            $domain .= '.'.$rootDomain;
194 194
         }
195 195
 
196 196
         if (false !== strpos($domain, '://')) {
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
             $scheme = $this->https || $request->isSsl() ? 'https://' : 'http://';
200 200
         }
201 201
 
202
-        return $scheme . $domain;
202
+        return $scheme.$domain;
203 203
     }
204 204
 
205 205
     /**
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
             }
219 219
         }
220 220
 
221
-        return (empty($suffix) || 0 === strpos($suffix, '.')) ? (string) $suffix : '.' . $suffix;
221
+        return (empty($suffix) || 0 === strpos($suffix, '.')) ? (string) $suffix : '.'.$suffix;
222 222
     }
223 223
 
224 224
     /**
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
                 $app        = empty($path) ? $app : array_pop($path);
256 256
             }
257 257
 
258
-            $url = $controller . '/' . $action;
258
+            $url = $controller.'/'.$action;
259 259
 
260 260
             if ($app && $this->app->config->get('app.auto_multi_app')) {
261 261
                 $bind = $this->app->config->get('app.domain_bind', []);
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
                     $map = $this->app->config->get('app.app_map', []);
266 266
 
267 267
                     if ($key = array_search($app, $map)) {
268
-                        $url = $key . '/' . $url;
268
+                        $url = $key.'/'.$url;
269 269
                     } else {
270
-                        $url = $app . '/' . $url;
270
+                        $url = $app.'/'.$url;
271 271
                     }
272 272
                 }
273 273
             }
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
     {
318 318
         $request = $this->app->request;
319 319
         if (is_string($allowDomain) && false === strpos($allowDomain, '.')) {
320
-            $allowDomain .= '.' . $request->rootDomain();
320
+            $allowDomain .= '.'.$request->rootDomain();
321 321
         }
322 322
 
323 323
         foreach ($rule as $item) {
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
             }
336 336
 
337 337
             if (!in_array($request->port(), [80, 443])) {
338
-                $domain .= ':' . $request->port();
338
+                $domain .= ':'.$request->port();
339 339
             }
340 340
 
341 341
             if (empty($pattern)) {
@@ -346,12 +346,12 @@  discard block
 block discarded – undo
346 346
 
347 347
             foreach ($pattern as $key => $val) {
348 348
                 if (isset($vars[$key])) {
349
-                    $url = str_replace(['[:' . $key . ']', '<' . $key . '?>', ':' . $key, '<' . $key . '>'], $type ? $vars[$key] : urlencode((string) $vars[$key]), $url);
349
+                    $url = str_replace(['[:'.$key.']', '<'.$key.'?>', ':'.$key, '<'.$key.'>'], $type ? $vars[$key] : urlencode((string) $vars[$key]), $url);
350 350
                     unset($vars[$key]);
351 351
                     $url    = str_replace(['/?', '-?'], ['/', '-'], $url);
352 352
                     $result = [rtrim($url, '?/-'), $domain, $suffix];
353 353
                 } elseif (2 == $val) {
354
-                    $url    = str_replace(['/[:' . $key . ']', '[:' . $key . ']', '<' . $key . '?>'], '', $url);
354
+                    $url    = str_replace(['/[:'.$key.']', '[:'.$key.']', '<'.$key.'?>'], '', $url);
355 355
                     $url    = str_replace(['/?', '-?'], ['/', '-'], $url);
356 356
                     $result = [rtrim($url, '?/-'), $domain, $suffix];
357 357
                 } else {
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
         if (0 === strpos($url, '[') && $pos = strpos($url, ']')) {
380 380
             // [name] 表示使用路由命名标识生成URL
381 381
             $name = substr($url, 1, $pos - 1);
382
-            $url  = 'name' . substr($url, $pos + 1);
382
+            $url  = 'name'.substr($url, $pos + 1);
383 383
         }
384 384
 
385 385
         if (false === strpos($url, '://') && 0 !== strpos($url, '/')) {
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
         }
407 407
 
408 408
         if ($url) {
409
-            $checkName   = isset($name) ? $name : $url . (isset($info['query']) ? '?' . $info['query'] : '');
409
+            $checkName   = isset($name) ? $name : $url.(isset($info['query']) ? '?'.$info['query'] : '');
410 410
             $checkDomain = $domain && is_string($domain) ? $domain : null;
411 411
 
412 412
             $rule = $this->route->getName($checkName, $checkDomain);
@@ -433,10 +433,10 @@  discard block
 block discarded – undo
433 433
             }
434 434
 
435 435
             if ($request->app() && $this->app->config->get('app.auto_multi_app') && !$this->app->http->isBindDomain()) {
436
-                $url = $request->app() . '/' . $url;
436
+                $url = $request->app().'/'.$url;
437 437
             }
438 438
         } elseif (!empty($rule) && isset($name)) {
439
-            throw new \InvalidArgumentException('route name not exists:' . $name);
439
+            throw new \InvalidArgumentException('route name not exists:'.$name);
440 440
         } else {
441 441
             // 检测URL绑定
442 442
             $bind = $this->route->getDomainBind($domain && is_string($domain) ? $domain : null);
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
             $file = str_replace('\\', '/', dirname($file));
475 475
         }
476 476
 
477
-        $url = rtrim($file, '/') . '/' . $url;
477
+        $url = rtrim($file, '/').'/'.$url;
478 478
 
479 479
         // URL后缀
480 480
         if ('/' == substr($url, -1) || '' == $url) {
@@ -484,32 +484,32 @@  discard block
 block discarded – undo
484 484
         }
485 485
 
486 486
         // 锚点
487
-        $anchor = !empty($anchor) ? '#' . $anchor : '';
487
+        $anchor = !empty($anchor) ? '#'.$anchor : '';
488 488
 
489 489
         // 参数组装
490 490
         if (!empty($vars)) {
491 491
             // 添加参数
492 492
             if ($this->route->config('url_common_param')) {
493 493
                 $vars = http_build_query($vars);
494
-                $url .= $suffix . '?' . $vars . $anchor;
494
+                $url .= $suffix.'?'.$vars.$anchor;
495 495
             } else {
496 496
                 foreach ($vars as $var => $val) {
497 497
                     if ('' !== $val) {
498
-                        $url .= $depr . $var . $depr . urlencode((string) $val);
498
+                        $url .= $depr.$var.$depr.urlencode((string) $val);
499 499
                     }
500 500
                 }
501 501
 
502
-                $url .= $suffix . $anchor;
502
+                $url .= $suffix.$anchor;
503 503
             }
504 504
         } else {
505
-            $url .= $suffix . $anchor;
505
+            $url .= $suffix.$anchor;
506 506
         }
507 507
 
508 508
         // 检测域名
509 509
         $domain = $this->parseDomain($url, $domain);
510 510
 
511 511
         // URL组装
512
-        return $domain . rtrim($this->root, '/') . '/' . ltrim($url, '/');
512
+        return $domain.rtrim($this->root, '/').'/'.ltrim($url, '/');
513 513
     }
514 514
 
515 515
     public function __toString()
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
 
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
     public function pipeline(string $type = 'global')
129 129
     {
130 130
         return (new Pipeline())
131
-            ->through(array_map(function ($middleware) {
132
-                return function ($request, $next) use ($middleware) {
131
+            ->through(array_map(function($middleware) {
132
+                return function($request, $next) use ($middleware) {
133 133
                     list($call, $param) = $middleware;
134 134
                     if (is_array($call) && is_string($call[0])) {
135 135
                         $call = [$this->app->make($call[0]), $call[1]];
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
     protected function sortMiddleware(array $middlewares)
227 227
     {
228 228
         $priority = $this->app->config->get('middleware.priority', []);
229
-        uasort($middlewares, function ($a, $b) use ($priority) {
229
+        uasort($middlewares, function($a, $b) use ($priority) {
230 230
             $aPriority = $this->getMiddlewarePriority($priority, $a);
231 231
             $bPriority = $this->getMiddlewarePriority($priority, $b);
232 232
             return $bPriority - $aPriority;
Please login to merge, or discard this patch.
src/think/route/dispatch/Url.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: 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
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         if ($bind && preg_match('/^[a-z]/is', $bind)) {
48 48
             $bind = str_replace('/', $depr, $bind);
49 49
             // 如果有域名绑定
50
-            $url = $bind . ('.' != substr($bind, -1) ? $depr : '') . ltrim($url, $depr);
50
+            $url = $bind.('.' != substr($bind, -1) ? $depr : '').ltrim($url, $depr);
51 51
         }
52 52
 
53 53
         $path = $this->rule->parseUrlPath($url);
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         $controller = !empty($path) ? array_shift($path) : null;
60 60
 
61 61
         if ($controller && !preg_match('/^[A-Za-z][\w|\.]*$/', $controller)) {
62
-            throw new HttpException(404, 'controller not exists:' . $controller);
62
+            throw new HttpException(404, 'controller not exists:'.$controller);
63 63
         }
64 64
 
65 65
         // 解析操作
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
         // 解析额外参数
70 70
         if ($path) {
71
-            preg_replace_callback('/(\w+)\|([^\|]+)/', function ($match) use (&$var) {
71
+            preg_replace_callback('/(\w+)\|([^\|]+)/', function($match) use (&$var) {
72 72
                 $var[$match[1]] = strip_tags($match[2]);
73 73
             }, implode('|', $path));
74 74
         }
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         $route = [$controller, $action];
87 87
 
88 88
         if ($this->hasDefinedRoute($route)) {
89
-            throw new HttpException(404, 'invalid request:' . str_replace('|', $depr, $url));
89
+            throw new HttpException(404, 'invalid request:'.str_replace('|', $depr, $url));
90 90
         }
91 91
 
92 92
         return $route;
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         list($controller, $action) = $route;
104 104
 
105 105
         // 检查地址是否被定义过路由
106
-        $name = strtolower(Str::studly($controller) . '/' . $action);
106
+        $name = strtolower(Str::studly($controller).'/'.$action);
107 107
 
108 108
         $host   = $this->request->host(true);
109 109
         $method = $this->request->method();
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
 
@@ -402,13 +402,13 @@  discard block
 block discarded – undo
402 402
         if (is_null($domain)) {
403 403
             $domain = $this->host;
404 404
         } elseif (false === strpos($domain, '.')) {
405
-            $domain .= '.' . $this->request->rootDomain();
405
+            $domain .= '.'.$this->request->rootDomain();
406 406
         }
407 407
 
408 408
         $subDomain = $this->request->subDomain();
409 409
 
410 410
         if (strpos($subDomain, '.')) {
411
-            $name = '*' . strstr($subDomain, '.');
411
+            $name = '*'.strstr($subDomain, '.');
412 412
         }
413 413
 
414 414
         if (isset($this->bind[$domain])) {
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
         $this->init();
741 741
 
742 742
         if ($withRoute) {
743
-            $checkCallback = function () use ($withRoute) {
743
+            $checkCallback = function() use ($withRoute) {
744 744
                 //加载路由
745 745
                 $withRoute();
746 746
                 return $this->check();
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 
762 762
         return $this->app->middleware->pipeline('route')
763 763
             ->send($request)
764
-            ->then(function () use ($dispatch) {
764
+            ->then(function() use ($dispatch) {
765 765
                 return $dispatch->run();
766 766
             });
767 767
     }
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
             $closure  = $this->config['route_check_cache_key'];
779 779
             $routeKey = $closure($request);
780 780
         } else {
781
-            $routeKey = md5($request->baseUrl(true) . ':' . $request->method());
781
+            $routeKey = md5($request->baseUrl(true).':'.$request->method());
782 782
         }
783 783
 
784 784
         return $routeKey;
@@ -828,10 +828,10 @@  discard block
 block discarded – undo
828 828
             $path = $pathinfo;
829 829
         } elseif ($suffix) {
830 830
             // 去除正常的URL后缀
831
-            $path = preg_replace('/\.(' . ltrim($suffix, '.') . ')$/i', '', $pathinfo);
831
+            $path = preg_replace('/\.('.ltrim($suffix, '.').')$/i', '', $pathinfo);
832 832
         } else {
833 833
             // 允许任何后缀访问
834
-            $path = preg_replace('/\.' . $this->request->ext() . '$/i', '', $pathinfo);
834
+            $path = preg_replace('/\.'.$this->request->ext().'$/i', '', $pathinfo);
835 835
         }
836 836
 
837 837
         return $path;
@@ -874,9 +874,9 @@  discard block
 block discarded – undo
874 874
                 $item = $this->domains[$this->host];
875 875
             } elseif (isset($this->domains[$subDomain])) {
876 876
                 $item = $this->domains[$subDomain];
877
-            } elseif (isset($this->domains['*.' . $domain2]) && !empty($domain3)) {
877
+            } elseif (isset($this->domains['*.'.$domain2]) && !empty($domain3)) {
878 878
                 // 泛三级域名
879
-                $item      = $this->domains['*.' . $domain2];
879
+                $item      = $this->domains['*.'.$domain2];
880 880
                 $panDomain = $domain3;
881 881
             } elseif (isset($this->domains['*']) && !empty($domain2)) {
882 882
                 // 泛二级域名
Please login to merge, or discard this patch.
src/think/console/command/RouteList.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
         }
49 49
 
50 50
         if ($app) {
51
-            $filename = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . $app . DIRECTORY_SEPARATOR . 'route_list.php';
51
+            $filename = $this->app->getRootPath().'runtime'.DIRECTORY_SEPARATOR.$app.DIRECTORY_SEPARATOR.'route_list.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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/think/App.php 1 patch
Spacing   +27 added lines, -27 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
 
@@ -180,14 +180,14 @@  discard block
 block discarded – undo
180 180
      */
181 181
     public function __construct(string $rootPath = '')
182 182
     {
183
-        $this->thinkPath   = dirname(__DIR__) . DIRECTORY_SEPARATOR;
184
-        $this->rootPath    = $rootPath ? rtrim($rootPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR : $this->getDefaultRootPath();
185
-        $this->appPath     = $this->rootPath . 'app' . DIRECTORY_SEPARATOR;
186
-        $this->runtimePath = $this->rootPath . 'runtime' . DIRECTORY_SEPARATOR;
187
-        $this->routePath   = $this->rootPath . 'route' . DIRECTORY_SEPARATOR;
183
+        $this->thinkPath   = dirname(__DIR__).DIRECTORY_SEPARATOR;
184
+        $this->rootPath    = $rootPath ? rtrim($rootPath, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR : $this->getDefaultRootPath();
185
+        $this->appPath     = $this->rootPath.'app'.DIRECTORY_SEPARATOR;
186
+        $this->runtimePath = $this->rootPath.'runtime'.DIRECTORY_SEPARATOR;
187
+        $this->routePath   = $this->rootPath.'route'.DIRECTORY_SEPARATOR;
188 188
 
189
-        if (is_file($this->appPath . 'provider.php')) {
190
-            $this->bind(include $this->appPath . 'provider.php');
189
+        if (is_file($this->appPath.'provider.php')) {
190
+            $this->bind(include $this->appPath.'provider.php');
191 191
         }
192 192
 
193 193
         static::setInstance($this);
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
     public function getService($service)
248 248
     {
249 249
         $name = is_string($service) ? $service : get_class($service);
250
-        return array_values(array_filter($this->services, function ($value) use ($name) {
250
+        return array_values(array_filter($this->services, function($value) use ($name) {
251 251
             return $value instanceof $name;
252 252
         }, ARRAY_FILTER_USE_BOTH))[0] ?? null;
253 253
     }
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
      */
405 405
     public function getBasePath(): string
406 406
     {
407
-        return $this->rootPath . 'app' . DIRECTORY_SEPARATOR;
407
+        return $this->rootPath.'app'.DIRECTORY_SEPARATOR;
408 408
     }
409 409
 
410 410
     /**
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
      */
463 463
     public function getConfigPath(): string
464 464
     {
465
-        return $this->rootPath . 'config' . DIRECTORY_SEPARATOR;
465
+        return $this->rootPath.'config'.DIRECTORY_SEPARATOR;
466 466
     }
467 467
 
468 468
     /**
@@ -508,8 +508,8 @@  discard block
 block discarded – undo
508 508
         $this->beginMem  = memory_get_usage();
509 509
 
510 510
         // 加载环境变量
511
-        if (is_file($this->rootPath . '.env')) {
512
-            $this->env->load($this->rootPath . '.env');
511
+        if (is_file($this->rootPath.'.env')) {
512
+            $this->env->load($this->rootPath.'.env');
513 513
         }
514 514
 
515 515
         $this->configExt = $this->env->get('config_ext', '.php');
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
         // 加载框架默认语言包
523 523
         $langSet = $this->lang->defaultLangSet();
524 524
 
525
-        $this->lang->load($this->thinkPath . 'lang' . DIRECTORY_SEPARATOR . $langSet . '.php');
525
+        $this->lang->load($this->thinkPath.'lang'.DIRECTORY_SEPARATOR.$langSet.'.php');
526 526
 
527 527
         // 加载应用默认语言包
528 528
         $this->loadLangPack($langSet);
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
         }
562 562
 
563 563
         // 加载系统语言包
564
-        $files = glob($this->appPath . 'lang' . DIRECTORY_SEPARATOR . $langset . '.*');
564
+        $files = glob($this->appPath.'lang'.DIRECTORY_SEPARATOR.$langset.'.*');
565 565
         $this->lang->load($files);
566 566
 
567 567
         // 加载扩展(自定义)语言包
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
      */
580 580
     public function boot(): void
581 581
     {
582
-        array_walk($this->services, function ($service) {
582
+        array_walk($this->services, function($service) {
583 583
             $this->bootService($service);
584 584
         });
585 585
     }
@@ -593,30 +593,30 @@  discard block
 block discarded – undo
593 593
     {
594 594
         $appPath = $this->getAppPath();
595 595
 
596
-        if (is_file($appPath . 'common.php')) {
597
-            include_once $appPath . 'common.php';
596
+        if (is_file($appPath.'common.php')) {
597
+            include_once $appPath.'common.php';
598 598
         }
599 599
 
600
-        include_once $this->thinkPath . 'helper.php';
600
+        include_once $this->thinkPath.'helper.php';
601 601
 
602 602
         $configPath = $this->getConfigPath();
603 603
 
604 604
         $files = [];
605 605
 
606 606
         if (is_dir($configPath)) {
607
-            $files = glob($configPath . '*' . $this->configExt);
607
+            $files = glob($configPath.'*'.$this->configExt);
608 608
         }
609 609
 
610 610
         foreach ($files as $file) {
611 611
             $this->config->load($file, pathinfo($file, PATHINFO_FILENAME));
612 612
         }
613 613
 
614
-        if (is_file($appPath . 'event.php')) {
615
-            $this->loadEvent(include $appPath . 'event.php');
614
+        if (is_file($appPath.'event.php')) {
615
+            $this->loadEvent(include $appPath.'event.php');
616 616
         }
617 617
 
618
-        if (is_file($appPath . 'service.php')) {
619
-            $services = include $appPath . 'service.php';
618
+        if (is_file($appPath.'service.php')) {
619
+            $services = include $appPath.'service.php';
620 620
             foreach ($services as $service) {
621 621
                 $this->register($service);
622 622
             }
@@ -681,9 +681,9 @@  discard block
 block discarded – undo
681 681
         $name  = str_replace(['/', '.'], '\\', $name);
682 682
         $array = explode('\\', $name);
683 683
         $class = Str::studly(array_pop($array));
684
-        $path  = $array ? implode('\\', $array) . '\\' : '';
684
+        $path  = $array ? implode('\\', $array).'\\' : '';
685 685
 
686
-        return $this->namespace . '\\' . $layer . '\\' . $path . $class;
686
+        return $this->namespace.'\\'.$layer.'\\'.$path.$class;
687 687
     }
688 688
 
689 689
     /**
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
     {
705 705
         $path = dirname(dirname(dirname(dirname($this->thinkPath))));
706 706
 
707
-        return $path . DIRECTORY_SEPARATOR;
707
+        return $path.DIRECTORY_SEPARATOR;
708 708
     }
709 709
 
710 710
 }
Please login to merge, or discard this patch.
src/think/Http.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: liu21st <[email protected]>
10 10
 // +----------------------------------------------------------------------
11
-declare (strict_types = 1);
11
+declare(strict_types=1);
12 12
 
13 13
 namespace think;
14 14
 
@@ -122,14 +122,14 @@  discard block
 block discarded – undo
122 122
 
123 123
         return $this->app->middleware->pipeline()
124 124
             ->send($request)
125
-            ->then(function ($request) {
125
+            ->then(function($request) {
126 126
                 return $this->dispatchToRoute($request);
127 127
             });
128 128
     }
129 129
 
130 130
     protected function dispatchToRoute($request)
131 131
     {
132
-        $withRoute = $this->app->config->get('app.with_route', true) ? function () {
132
+        $withRoute = $this->app->config->get('app.with_route', true) ? function() {
133 133
             $this->loadRoutes();
134 134
         } : null;
135 135
 
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
      */
142 142
     protected function loadMiddleware(): void
143 143
     {
144
-        if (is_file($this->app->getBasePath() . 'middleware.php')) {
145
-            $this->app->middleware->import(include $this->app->getBasePath() . 'middleware.php');
144
+        if (is_file($this->app->getBasePath().'middleware.php')) {
145
+            $this->app->middleware->import(include $this->app->getBasePath().'middleware.php');
146 146
         }
147 147
     }
148 148
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
         $routePath = $this->app->getRoutePath();
158 158
 
159 159
         if (is_dir($routePath)) {
160
-            $files = glob($routePath . '*.php');
160
+            $files = glob($routePath.'*.php');
161 161
             foreach ($files as $file) {
162 162
                 include $file;
163 163
             }
Please login to merge, or discard this patch.
tests/HttpTest.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
         $route = m::mock(Route::class);
49 49
 
50
-        $route->shouldReceive('dispatch')->withArgs(function ($req, $withRoute) use ($request) {
50
+        $route->shouldReceive('dispatch')->withArgs(function($req, $withRoute) use ($request) {
51 51
             if ($withRoute) {
52 52
                 $withRoute();
53 53
             }
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 
80 80
         $this->http->multi(false);
81 81
 
82
-        $this->app->shouldReceive('getBasePath')->andReturn($root->getChild('app')->url() . DIRECTORY_SEPARATOR);
83
-        $this->app->shouldReceive('getRootPath')->andReturn($root->url() . DIRECTORY_SEPARATOR);
82
+        $this->app->shouldReceive('getBasePath')->andReturn($root->getChild('app')->url().DIRECTORY_SEPARATOR);
83
+        $this->app->shouldReceive('getRootPath')->andReturn($root->url().DIRECTORY_SEPARATOR);
84 84
 
85 85
         $request  = m::mock(Request::class)->makePartial();
86 86
         $response = m::mock(Response::class)->makePartial();
Please login to merge, or discard this patch.