@@ -13,7 +13,7 @@ |
||
13 | 13 | public function __construct(string $message, string $func = '', Throwable $previous = null) |
14 | 14 | { |
15 | 15 | $this->message = $message; |
16 | - $this->func = $func; |
|
16 | + $this->func = $func; |
|
17 | 17 | |
18 | 18 | parent::__construct($message, 0, $previous); |
19 | 19 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | Container::setInstance($container); |
65 | 65 | |
66 | - $container->bind('name', function () { |
|
66 | + $container->bind('name', function() { |
|
67 | 67 | return 'Taylor'; |
68 | 68 | }); |
69 | 69 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $this->expectExceptionMessage('class not exists: name'); |
81 | 81 | $container->get('name'); |
82 | 82 | |
83 | - $container->bind('name', function () { |
|
83 | + $container->bind('name', function() { |
|
84 | 84 | return 'Taylor'; |
85 | 85 | }); |
86 | 86 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | { |
92 | 92 | $container = new Container; |
93 | 93 | |
94 | - $container->bind('name', function () { |
|
94 | + $container->bind('name', function() { |
|
95 | 95 | return 'Taylor'; |
96 | 96 | }); |
97 | 97 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | { |
107 | 107 | $container = new Container; |
108 | 108 | |
109 | - $container->bind('name', function () { |
|
109 | + $container->bind('name', function() { |
|
110 | 110 | return 'Taylor'; |
111 | 111 | }); |
112 | 112 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | |
199 | 199 | $this->assertSame($object, Container::getInstance()); |
200 | 200 | |
201 | - Container::setInstance(function () { |
|
201 | + Container::setInstance(function() { |
|
202 | 202 | return $this; |
203 | 203 | }); |
204 | 204 | |
@@ -210,10 +210,10 @@ discard block |
||
210 | 210 | $container = new Container(); |
211 | 211 | $container->bind(Container::class, $container); |
212 | 212 | |
213 | - $container->resolving(function (SomeClass $taylor, Container $container) { |
|
213 | + $container->resolving(function(SomeClass $taylor, Container $container) { |
|
214 | 214 | $taylor->count++; |
215 | 215 | }); |
216 | - $container->resolving(SomeClass::class, function (SomeClass $taylor, Container $container) { |
|
216 | + $container->resolving(SomeClass::class, function(SomeClass $taylor, Container $container) { |
|
217 | 217 | $taylor->count++; |
218 | 218 | }); |
219 | 219 | |
@@ -252,19 +252,19 @@ discard block |
||
252 | 252 | |
253 | 253 | $this->assertEquals('48', $container->invoke('ord', ['0'])); |
254 | 254 | |
255 | - $this->assertSame($container, $container->invoke(Taylor::class . '::test', [])); |
|
255 | + $this->assertSame($container, $container->invoke(Taylor::class.'::test', [])); |
|
256 | 256 | |
257 | - $this->assertSame($container, $container->invokeMethod(Taylor::class . '::test')); |
|
257 | + $this->assertSame($container, $container->invokeMethod(Taylor::class.'::test')); |
|
258 | 258 | |
259 | 259 | $reflect = new ReflectionMethod($container, 'exists'); |
260 | 260 | |
261 | 261 | $this->assertTrue($container->invokeReflectMethod($container, $reflect, [Container::class])); |
262 | 262 | |
263 | - $this->assertSame($container, $container->invoke(function (Container $container) { |
|
263 | + $this->assertSame($container, $container->invoke(function(Container $container) { |
|
264 | 264 | return $container; |
265 | 265 | })); |
266 | 266 | |
267 | - $this->assertSame($container, $container->invoke(Taylor::class . '::test')); |
|
267 | + $this->assertSame($container, $container->invoke(Taylor::class.'::test')); |
|
268 | 268 | |
269 | 269 | $object = $container->invokeClass(SomeClass::class); |
270 | 270 | $this->assertInstanceOf(SomeClass::class, $object); |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | |
273 | 273 | $stdClass = new stdClass(); |
274 | 274 | |
275 | - $container->invoke(function (Container $container, stdClass $stdObject, $key1, $lowKey, $key2 = 'default') use ($stdClass) { |
|
275 | + $container->invoke(function(Container $container, stdClass $stdObject, $key1, $lowKey, $key2 = 'default') use ($stdClass) { |
|
276 | 276 | $this->assertEquals('value1', $key1); |
277 | 277 | $this->assertEquals('default', $key2); |
278 | 278 | $this->assertEquals('value2', $lowKey); |
@@ -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\middleware; |
14 | 14 | |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | |
89 | 89 | if (isset($key) && 200 == $response->getCode() && $response->isAllowCache()) { |
90 | 90 | $header = $response->getHeader(); |
91 | - $header['Cache-Control'] = 'max-age=' . $expire . ',must-revalidate'; |
|
92 | - $header['Last-Modified'] = gmdate('D, d M Y H:i:s') . ' GMT'; |
|
93 | - $header['Expires'] = gmdate('D, d M Y H:i:s', time() + $expire) . ' GMT'; |
|
91 | + $header['Cache-Control'] = 'max-age='.$expire.',must-revalidate'; |
|
92 | + $header['Last-Modified'] = gmdate('D, d M Y H:i:s').' GMT'; |
|
93 | + $header['Expires'] = gmdate('D, d M Y H:i:s', time() + $expire).' GMT'; |
|
94 | 94 | |
95 | 95 | $this->cache->tag($tag)->set($key, [$response->getContent(), $header, time()], $expire); |
96 | 96 | } |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | if (false !== strpos($key, ':')) { |
142 | 142 | $param = $request->param(); |
143 | 143 | foreach ($param as $item => $val) { |
144 | - if (is_string($val) && false !== strpos($key, ':' . $item)) { |
|
145 | - $key = str_replace(':' . $item, $val, $key); |
|
144 | + if (is_string($val) && false !== strpos($key, ':'.$item)) { |
|
145 | + $key = str_replace(':'.$item, $val, $key); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | } elseif (strpos($key, ']')) { |
149 | - if ('[' . $request->ext() . ']' == $key) { |
|
149 | + if ('['.$request->ext().']' == $key) { |
|
150 | 150 | // 缓存某个后缀的请求 |
151 | 151 | $key = md5($request->url()); |
152 | 152 | } else { |
@@ -8,7 +8,7 @@ |
||
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\response; |
14 | 14 |
@@ -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(); |