@@ -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 | |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | */ |
| 368 | 368 | public function hasScene(string $name): bool |
| 369 | 369 | { |
| 370 | - return isset($this->scene[$name]) || method_exists($this, 'scene' . $name); |
|
| 370 | + return isset($this->scene[$name]) || method_exists($this, 'scene'.$name); |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | /** |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | if (strpos($field, '_confirm')) { |
| 720 | 720 | $rule = strstr($field, '_confirm', true); |
| 721 | 721 | } else { |
| 722 | - $rule = $field . '_confirm'; |
|
| 722 | + $rule = $field.'_confirm'; |
|
| 723 | 723 | } |
| 724 | 724 | } |
| 725 | 725 | |
@@ -870,9 +870,9 @@ discard block |
||
| 870 | 870 | if (isset($this->type[$rule])) { |
| 871 | 871 | // 注册的验证规则 |
| 872 | 872 | $result = call_user_func_array($this->type[$rule], [$value]); |
| 873 | - } elseif (function_exists('ctype_' . $rule)) { |
|
| 873 | + } elseif (function_exists('ctype_'.$rule)) { |
|
| 874 | 874 | // ctype验证规则 |
| 875 | - $ctypeFun = 'ctype_' . $rule; |
|
| 875 | + $ctypeFun = 'ctype_'.$rule; |
|
| 876 | 876 | $result = $ctypeFun($value); |
| 877 | 877 | } elseif (isset($this->filter[$rule])) { |
| 878 | 878 | // Filter_var验证规则 |
@@ -1510,7 +1510,7 @@ discard block |
||
| 1510 | 1510 | |
| 1511 | 1511 | if (is_string($rule) && 0 !== strpos($rule, '/') && !preg_match('/\/[imsU]{0,4}$/', $rule)) { |
| 1512 | 1512 | // 不是正则表达式则两端补上/ |
| 1513 | - $rule = '/^' . $rule . '$/'; |
|
| 1513 | + $rule = '/^'.$rule.'$/'; |
|
| 1514 | 1514 | } |
| 1515 | 1515 | |
| 1516 | 1516 | return is_scalar($value) && 1 === preg_match($rule, (string) $value); |
@@ -1560,8 +1560,8 @@ discard block |
||
| 1560 | 1560 | */ |
| 1561 | 1561 | protected function getRuleMsg(string $attribute, string $title, string $type, $rule) |
| 1562 | 1562 | { |
| 1563 | - if (isset($this->message[$attribute . '.' . $type])) { |
|
| 1564 | - $msg = $this->message[$attribute . '.' . $type]; |
|
| 1563 | + if (isset($this->message[$attribute.'.'.$type])) { |
|
| 1564 | + $msg = $this->message[$attribute.'.'.$type]; |
|
| 1565 | 1565 | } elseif (isset($this->message[$attribute][$type])) { |
| 1566 | 1566 | $msg = $this->message[$attribute][$type]; |
| 1567 | 1567 | } elseif (isset($this->message[$attribute])) { |
@@ -1571,7 +1571,7 @@ discard block |
||
| 1571 | 1571 | } elseif (0 === strpos($type, 'require')) { |
| 1572 | 1572 | $msg = $this->typeMsg['require']; |
| 1573 | 1573 | } else { |
| 1574 | - $msg = $title . $this->lang->get('not conform to the rules'); |
|
| 1574 | + $msg = $title.$this->lang->get('not conform to the rules'); |
|
| 1575 | 1575 | } |
| 1576 | 1576 | |
| 1577 | 1577 | if (is_array($msg)) { |
@@ -1633,8 +1633,8 @@ discard block |
||
| 1633 | 1633 | { |
| 1634 | 1634 | $this->only = $this->append = $this->remove = []; |
| 1635 | 1635 | |
| 1636 | - if (method_exists($this, 'scene' . $scene)) { |
|
| 1637 | - call_user_func([$this, 'scene' . $scene]); |
|
| 1636 | + if (method_exists($this, 'scene'.$scene)) { |
|
| 1637 | + call_user_func([$this, 'scene'.$scene]); |
|
| 1638 | 1638 | } elseif (isset($this->scene[$scene])) { |
| 1639 | 1639 | // 如果设置了验证适用场景 |
| 1640 | 1640 | $this->only = $this->scene[$scene]; |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | { |
| 43 | 43 | $this->event->bind(['foo' => 'baz']); |
| 44 | 44 | |
| 45 | - $this->event->listen('foo', function ($bar) { |
|
| 45 | + $this->event->listen('foo', function($bar) { |
|
| 46 | 46 | $this->assertEquals('bar', $bar); |
| 47 | 47 | }); |
| 48 | 48 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | public function testOnceEvent() |
| 59 | 59 | { |
| 60 | - $this->event->listen('AppInit', function ($bar) { |
|
| 60 | + $this->event->listen('AppInit', function($bar) { |
|
| 61 | 61 | $this->assertEquals('bar', $bar); |
| 62 | 62 | return 'foo'; |
| 63 | 63 | }); |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | { |
| 82 | 82 | $listener = m::mock("overload:SomeListener", TestListener::class); |
| 83 | 83 | |
| 84 | - $listener->shouldReceive('subscribe')->andReturnUsing(function (Event $event) use ($listener) { |
|
| 84 | + $listener->shouldReceive('subscribe')->andReturnUsing(function(Event $event) use ($listener) { |
|
| 85 | 85 | |
| 86 | 86 | $listener->shouldReceive('onBar')->once()->andReturnFalse(); |
| 87 | 87 | |
@@ -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 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | foreach ($methods as $method) { |
| 222 | 222 | $name = $method->getName(); |
| 223 | 223 | if (0 === strpos($name, 'on')) { |
| 224 | - $this->listen($prefix . substr($name, 2), [$observer, $name]); |
|
| 224 | + $this->listen($prefix.substr($name, 2), [$observer, $name]); |
|
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | |
@@ -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\filesystem; |
| 14 | 14 | |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | public function putFileAs(string $path, File $file, string $name, array $options = []) |
| 116 | 116 | { |
| 117 | 117 | $stream = fopen($file->getRealPath(), 'r'); |
| 118 | - $path = trim($path . '/' . $name, '/'); |
|
| 118 | + $path = trim($path.'/'.$name, '/'); |
|
| 119 | 119 | |
| 120 | 120 | $result = $this->putStream($path, $stream, $options); |
| 121 | 121 | |
@@ -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\exception; |
| 14 | 14 | |
@@ -69,11 +69,11 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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; |
@@ -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 | |
@@ -47,7 +47,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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(); |
@@ -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 | |
@@ -170,9 +170,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | // 泛二级域名 |
@@ -47,7 +47,7 @@ discard block |
||
| 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 | } |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | ], |
| 78 | 78 | ]); |
| 79 | 79 | |
| 80 | - $this->app->shouldReceive('getBasePath')->andReturn($root->getChild('app')->url() . DIRECTORY_SEPARATOR); |
|
| 81 | - $this->app->shouldReceive('getRootPath')->andReturn($root->url() . DIRECTORY_SEPARATOR); |
|
| 80 | + $this->app->shouldReceive('getBasePath')->andReturn($root->getChild('app')->url().DIRECTORY_SEPARATOR); |
|
| 81 | + $this->app->shouldReceive('getRootPath')->andReturn($root->url().DIRECTORY_SEPARATOR); |
|
| 82 | 82 | |
| 83 | 83 | $request = m::mock(Request::class)->makePartial(); |
| 84 | 84 | $response = m::mock(Response::class)->makePartial(); |