@@ -118,7 +118,7 @@ |
||
118 | 118 | */ |
119 | 119 | public function setId($id = null): void |
120 | 120 | { |
121 | - $this->id = is_string($id) && strlen($id) === 32 ? $id : md5(microtime(true) . session_create_id()); |
|
121 | + $this->id = is_string($id) && strlen($id) === 32 ? $id : md5(microtime(true).session_create_id()); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -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 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public static function create($data = '', string $type = 'html', int $code = 200): Response |
104 | 104 | { |
105 | - $class = false !== strpos($type, '\\') ? $type : '\\think\\response\\' . ucfirst(strtolower($type)); |
|
105 | + $class = false !== strpos($type, '\\') ? $type : '\\think\\response\\'.ucfirst(strtolower($type)); |
|
106 | 106 | |
107 | 107 | return Container::getInstance()->invokeClass($class, [$data, $code]); |
108 | 108 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | http_response_code($this->code); |
136 | 136 | // 发送头部信息 |
137 | 137 | foreach ($this->header as $name => $val) { |
138 | - header($name . (!is_null($val) ? ':' . $val : '')); |
|
138 | + header($name.(!is_null($val) ? ':'.$val : '')); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | if ($this->cookie) { |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | */ |
345 | 345 | public function contentType(string $contentType, string $charset = 'utf-8') |
346 | 346 | { |
347 | - $this->header['Content-Type'] = $contentType . '; charset=' . $charset; |
|
347 | + $this->header['Content-Type'] = $contentType.'; charset='.$charset; |
|
348 | 348 | |
349 | 349 | return $this; |
350 | 350 | } |
@@ -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\cache\driver; |
14 | 14 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $this->handler = new \Redis; |
59 | 59 | |
60 | 60 | if ($this->options['persistent']) { |
61 | - $this->handler->pconnect($this->options['host'], (int) $this->options['port'], (int) $this->options['timeout'], 'persistent_id_' . $this->options['select']); |
|
61 | + $this->handler->pconnect($this->options['host'], (int) $this->options['port'], (int) $this->options['timeout'], 'persistent_id_'.$this->options['select']); |
|
62 | 62 | } else { |
63 | 63 | $this->handler->connect($this->options['host'], (int) $this->options['port'], (int) $this->options['timeout']); |
64 | 64 | } |
@@ -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\cache\driver; |
14 | 14 | |
@@ -64,8 +64,7 @@ discard block |
||
64 | 64 | foreach ($hosts as $i => $host) { |
65 | 65 | $port = $ports[$i] ?? $ports[0]; |
66 | 66 | $this->options['timeout'] > 0 ? |
67 | - $this->handler->addServer($host, (int) $port, $this->options['persistent'], 1, (int) $this->options['timeout']) : |
|
68 | - $this->handler->addServer($host, (int) $port, $this->options['persistent'], 1); |
|
67 | + $this->handler->addServer($host, (int) $port, $this->options['persistent'], 1, (int) $this->options['timeout']) : $this->handler->addServer($host, (int) $port, $this->options['persistent'], 1); |
|
69 | 68 | } |
70 | 69 | } |
71 | 70 | |
@@ -177,8 +176,7 @@ discard block |
||
177 | 176 | $key = $this->getCacheKey($name); |
178 | 177 | |
179 | 178 | return false === $ttl ? |
180 | - $this->handler->delete($key) : |
|
181 | - $this->handler->delete($key, $ttl); |
|
179 | + $this->handler->delete($key) : $this->handler->delete($key, $ttl); |
|
182 | 180 | } |
183 | 181 | |
184 | 182 | /** |
@@ -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 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | return $this->make($abstract); |
131 | 131 | } |
132 | 132 | |
133 | - throw new ClassNotFoundException('class not exists: ' . $abstract, $abstract); |
|
133 | + throw new ClassNotFoundException('class not exists: '.$abstract, $abstract); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | $reflect = new ReflectionMethod($class, $method); |
316 | 316 | } catch (ReflectionException $e) { |
317 | 317 | $class = is_object($class) ? get_class($class) : $class; |
318 | - throw new FuncNotFoundException('method not exists: ' . $class . '::' . $method . '()', "{$class}::{$method}", $e); |
|
318 | + throw new FuncNotFoundException('method not exists: '.$class.'::'.$method.'()', "{$class}::{$method}", $e); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | $args = $this->bindParams($reflect, $vars); |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | try { |
374 | 374 | $reflect = new ReflectionClass($class); |
375 | 375 | } catch (ReflectionException $e) { |
376 | - throw new ClassNotFoundException('class not exists: ' . $class, $class, $e); |
|
376 | + throw new ClassNotFoundException('class not exists: '.$class, $class, $e); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | if ($reflect->hasMethod('__make')) { |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | } elseif ($param->isDefaultValueAvailable()) { |
453 | 453 | $args[] = $param->getDefaultValue(); |
454 | 454 | } else { |
455 | - throw new InvalidArgumentException('method param miss:' . $name); |
|
455 | + throw new InvalidArgumentException('method param miss:'.$name); |
|
456 | 456 | } |
457 | 457 | } |
458 | 458 | |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | */ |
471 | 471 | public static function factory(string $name, string $namespace = '', ...$args) |
472 | 472 | { |
473 | - $class = false !== strpos($name, '\\') ? $name : $namespace . ucwords($name); |
|
473 | + $class = false !== strpos($name, '\\') ? $name : $namespace.ucwords($name); |
|
474 | 474 | |
475 | 475 | return Container::getInstance()->invokeClass($class, $args); |
476 | 476 | } |
@@ -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-z0-9][\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 | [$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: Slince <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think; |
14 | 14 | |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | public function pipeline(string $type = 'global') |
134 | 134 | { |
135 | 135 | return (new Pipeline()) |
136 | - ->through(array_map(function ($middleware) { |
|
137 | - return function ($request, $next) use ($middleware) { |
|
136 | + ->through(array_map(function($middleware) { |
|
137 | + return function($request, $next) use ($middleware) { |
|
138 | 138 | [$call, $param] = $middleware; |
139 | 139 | if (is_array($call) && is_string($call[0])) { |
140 | 140 | $call = [$this->app->make($call[0]), $call[1]]; |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | protected function sortMiddleware(array $middlewares) |
232 | 232 | { |
233 | 233 | $priority = $this->app->config->get('middleware.priority', []); |
234 | - uasort($middlewares, function ($a, $b) use ($priority) { |
|
234 | + uasort($middlewares, function($a, $b) use ($priority) { |
|
235 | 235 | $aPriority = $this->getMiddlewarePriority($priority, $a); |
236 | 236 | $bPriority = $this->getMiddlewarePriority($priority, $b); |
237 | 237 | return $bPriority - $aPriority; |
@@ -126,10 +126,10 @@ |
||
126 | 126 | $redis->shouldReceive("del")->once()->with('baz')->andReturnTrue(); |
127 | 127 | $redis->shouldReceive("flushDB")->once()->andReturnTrue(); |
128 | 128 | $redis->shouldReceive("set")->once()->with('bar', serialize('foobar'))->andReturnTrue(); |
129 | - $redis->shouldReceive("sAdd")->once()->with('tag:' . md5('foo'), 'bar')->andReturnTrue(); |
|
130 | - $redis->shouldReceive("sMembers")->once()->with('tag:' . md5('foo'))->andReturn(['bar']); |
|
129 | + $redis->shouldReceive("sAdd")->once()->with('tag:'.md5('foo'), 'bar')->andReturnTrue(); |
|
130 | + $redis->shouldReceive("sMembers")->once()->with('tag:'.md5('foo'))->andReturn(['bar']); |
|
131 | 131 | $redis->shouldReceive("del")->once()->with(['bar'])->andReturnTrue(); |
132 | - $redis->shouldReceive("del")->once()->with('tag:' . md5('foo'))->andReturnTrue(); |
|
132 | + $redis->shouldReceive("del")->once()->with('tag:'.md5('foo'))->andReturnTrue(); |
|
133 | 133 | |
134 | 134 | $this->cache->set('foo', 5); |
135 | 135 | $this->cache->inc('foo'); |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: luofei614 <weibo.com/luofei614> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\log\driver; |
14 | 14 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | if ($this->app->exists('request')) { |
93 | 93 | $current_uri = $this->app->request->url(true); |
94 | 94 | } else { |
95 | - $current_uri = 'cmd:' . implode(' ', $_SERVER['argv'] ?? []); |
|
95 | + $current_uri = 'cmd:'.implode(' ', $_SERVER['argv'] ?? []); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | if (!empty($this->config['format_head'])) { |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | foreach ($log as $type => $val) { |
117 | 117 | $trace[] = [ |
118 | 118 | 'type' => ($expand_level[$type] ?? false) ? 'group' : 'groupCollapsed', |
119 | - 'msg' => '[ ' . $type . ' ]', |
|
119 | + 'msg' => '[ '.$type.' ]', |
|
120 | 120 | 'css' => $this->css[$type] ?? '', |
121 | 121 | ]; |
122 | 122 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | ]; |
203 | 203 | |
204 | 204 | $msg = json_encode($logs, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR); |
205 | - $address = '/' . $client_id; //将client_id作为地址, server端通过地址判断将日志发布给谁 |
|
205 | + $address = '/'.$client_id; //将client_id作为地址, server端通过地址判断将日志发布给谁 |
|
206 | 206 | |
207 | 207 | $this->send($this->config['host'], $this->config['port'], $msg, $address); |
208 | 208 | } |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | */ |
286 | 286 | protected function send($host, $port, $message = '', $address = '/') |
287 | 287 | { |
288 | - $url = 'http://' . $host . ':' . $port . $address; |
|
288 | + $url = 'http://'.$host.':'.$port.$address; |
|
289 | 289 | $ch = curl_init(); |
290 | 290 | |
291 | 291 | curl_setopt($ch, CURLOPT_URL, $url); |