@@ -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(); |
@@ -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: liu21st <[email protected]> |
| 10 | 10 | // +---------------------------------------------------------------------- |
| 11 | -declare (strict_types = 1); |
|
| 11 | +declare(strict_types=1); |
|
| 12 | 12 | |
| 13 | 13 | namespace think\view\driver; |
| 14 | 14 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | // 模板不存在 抛出异常 |
| 80 | 80 | if (!is_file($template)) { |
| 81 | - throw new RuntimeException('template not exists:' . $template); |
|
| 81 | + throw new RuntimeException('template not exists:'.$template); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $this->template = $template; |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $this->content = $content; |
| 101 | 101 | |
| 102 | 102 | extract($data, EXTR_OVERWRITE); |
| 103 | - eval('?>' . $this->content); |
|
| 103 | + eval('?>'.$this->content); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -125,10 +125,10 @@ discard block |
||
| 125 | 125 | $appName = isset($app) ? $app : $this->app->http->getName(); |
| 126 | 126 | $view = $this->config['view_dir_name']; |
| 127 | 127 | |
| 128 | - if (is_dir($this->app->getAppPath() . $view)) { |
|
| 129 | - $path = isset($app) ? $this->app->getBasePath() . ($appName ? $appName . DIRECTORY_SEPARATOR : '') . $view . DIRECTORY_SEPARATOR : $this->app->getAppPath() . $view . DIRECTORY_SEPARATOR; |
|
| 128 | + if (is_dir($this->app->getAppPath().$view)) { |
|
| 129 | + $path = isset($app) ? $this->app->getBasePath().($appName ? $appName.DIRECTORY_SEPARATOR : '').$view.DIRECTORY_SEPARATOR : $this->app->getAppPath().$view.DIRECTORY_SEPARATOR; |
|
| 130 | 130 | } else { |
| 131 | - $path = $this->app->getRootPath() . $view . DIRECTORY_SEPARATOR . ($appName ? $appName . DIRECTORY_SEPARATOR : ''); |
|
| 131 | + $path = $this->app->getRootPath().$view.DIRECTORY_SEPARATOR.($appName ? $appName.DIRECTORY_SEPARATOR : ''); |
|
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $controller = $request->controller(); |
| 140 | 140 | if (strpos($controller, '.')) { |
| 141 | 141 | $pos = strrpos($controller, '.'); |
| 142 | - $controller = substr($controller, 0, $pos) . '.' . Str::snake(substr($controller, $pos + 1)); |
|
| 142 | + $controller = substr($controller, 0, $pos).'.'.Str::snake(substr($controller, $pos + 1)); |
|
| 143 | 143 | } else { |
| 144 | 144 | $controller = Str::snake($controller); |
| 145 | 145 | } |
@@ -155,16 +155,16 @@ discard block |
||
| 155 | 155 | $template = Str::snake($request->action()); |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template; |
|
| 158 | + $template = str_replace('.', DIRECTORY_SEPARATOR, $controller).$depr.$template; |
|
| 159 | 159 | } elseif (false === strpos($template, $depr)) { |
| 160 | - $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template; |
|
| 160 | + $template = str_replace('.', DIRECTORY_SEPARATOR, $controller).$depr.$template; |
|
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | } else { |
| 164 | 164 | $template = str_replace(['/', ':'], $depr, substr($template, 1)); |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - return $path . ltrim($template, '/') . '.' . ltrim($this->config['view_suffix'], '.'); |
|
| 167 | + return $path.ltrim($template, '/').'.'.ltrim($this->config['view_suffix'], '.'); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -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; |
| 14 | 14 | |
@@ -190,7 +190,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | /** |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | // 解析到控制器 |
| 243 | 243 | $url = substr($url, 1); |
| 244 | 244 | } elseif ('' === $url) { |
| 245 | - $url = $request->controller() . '/' . $request->action(); |
|
| 245 | + $url = $request->controller().'/'.$request->action(); |
|
| 246 | 246 | } else { |
| 247 | 247 | $controller = $request->controller(); |
| 248 | 248 | |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | $action = array_pop($path); |
| 251 | 251 | $controller = empty($path) ? $controller : array_pop($path); |
| 252 | 252 | |
| 253 | - $url = $controller . '/' . $action; |
|
| 253 | + $url = $controller.'/'.$action; |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | return $url; |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | { |
| 298 | 298 | $request = $this->app->request; |
| 299 | 299 | if (is_string($allowDomain) && false === strpos($allowDomain, '.')) { |
| 300 | - $allowDomain .= '.' . $request->rootDomain(); |
|
| 300 | + $allowDomain .= '.'.$request->rootDomain(); |
|
| 301 | 301 | } |
| 302 | 302 | $port = $request->port(); |
| 303 | 303 | |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | if ($port && !in_array($port, [80, 443])) { |
| 319 | - $domain .= ':' . $port; |
|
| 319 | + $domain .= ':'.$port; |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | if (empty($pattern)) { |
@@ -328,12 +328,12 @@ discard block |
||
| 328 | 328 | |
| 329 | 329 | foreach ($pattern as $key => $val) { |
| 330 | 330 | if (isset($vars[$key])) { |
| 331 | - $url = str_replace(['[:' . $key . ']', '<' . $key . '?>', ':' . $key, '<' . $key . '>'], $type ? $vars[$key] : urlencode((string) $vars[$key]), $url); |
|
| 331 | + $url = str_replace(['[:'.$key.']', '<'.$key.'?>', ':'.$key, '<'.$key.'>'], $type ? $vars[$key] : urlencode((string) $vars[$key]), $url); |
|
| 332 | 332 | $keys[] = $key; |
| 333 | 333 | $url = str_replace(['/?', '-?'], ['/', '-'], $url); |
| 334 | 334 | $result = [rtrim($url, '?/-'), $domain, $suffix]; |
| 335 | 335 | } elseif (2 == $val) { |
| 336 | - $url = str_replace(['/[:' . $key . ']', '[:' . $key . ']', '<' . $key . '?>'], '', $url); |
|
| 336 | + $url = str_replace(['/[:'.$key.']', '[:'.$key.']', '<'.$key.'?>'], '', $url); |
|
| 337 | 337 | $url = str_replace(['/?', '-?'], ['/', '-'], $url); |
| 338 | 338 | $result = [rtrim($url, '?/-'), $domain, $suffix]; |
| 339 | 339 | } else { |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | if (0 === strpos($url, '[') && $pos = strpos($url, ']')) { |
| 366 | 366 | // [name] 表示使用路由命名标识生成URL |
| 367 | 367 | $name = substr($url, 1, $pos - 1); |
| 368 | - $url = 'name' . substr($url, $pos + 1); |
|
| 368 | + $url = 'name'.substr($url, $pos + 1); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | if (false === strpos($url, '://') && 0 !== strpos($url, '/')) { |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | if ($url) { |
| 395 | - $checkName = isset($name) ? $name : $url . (isset($info['query']) ? '?' . $info['query'] : ''); |
|
| 395 | + $checkName = isset($name) ? $name : $url.(isset($info['query']) ? '?'.$info['query'] : ''); |
|
| 396 | 396 | $checkDomain = $domain && is_string($domain) ? $domain : null; |
| 397 | 397 | |
| 398 | 398 | $rule = $this->route->getName($checkName, $checkDomain); |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | $suffix = $match[2]; |
| 419 | 419 | } |
| 420 | 420 | } elseif (!empty($rule) && isset($name)) { |
| 421 | - throw new \InvalidArgumentException('route name not exists:' . $name); |
|
| 421 | + throw new \InvalidArgumentException('route name not exists:'.$name); |
|
| 422 | 422 | } else { |
| 423 | 423 | // 检测URL绑定 |
| 424 | 424 | $bind = $this->route->getDomainBind($domain && is_string($domain) ? $domain : null); |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | $file = str_replace('\\', '/', dirname($file)); |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | - $url = rtrim($file, '/') . '/' . $url; |
|
| 459 | + $url = rtrim($file, '/').'/'.$url; |
|
| 460 | 460 | |
| 461 | 461 | // URL后缀 |
| 462 | 462 | if ('/' == substr($url, -1) || '' == $url) { |
@@ -466,33 +466,33 @@ discard block |
||
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | // 锚点 |
| 469 | - $anchor = !empty($anchor) ? '#' . $anchor : ''; |
|
| 469 | + $anchor = !empty($anchor) ? '#'.$anchor : ''; |
|
| 470 | 470 | |
| 471 | 471 | // 参数组装 |
| 472 | 472 | if (!empty($vars)) { |
| 473 | 473 | // 添加参数 |
| 474 | 474 | if ($this->route->config('url_common_param')) { |
| 475 | 475 | $vars = http_build_query($vars); |
| 476 | - $url .= $suffix . '?' . $vars . $anchor; |
|
| 476 | + $url .= $suffix.'?'.$vars.$anchor; |
|
| 477 | 477 | } else { |
| 478 | 478 | foreach ($vars as $var => $val) { |
| 479 | 479 | $val = (string) $val; |
| 480 | 480 | if ('' !== $val) { |
| 481 | - $url .= $depr . $var . $depr . urlencode($val); |
|
| 481 | + $url .= $depr.$var.$depr.urlencode($val); |
|
| 482 | 482 | } |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | - $url .= $suffix . $anchor; |
|
| 485 | + $url .= $suffix.$anchor; |
|
| 486 | 486 | } |
| 487 | 487 | } else { |
| 488 | - $url .= $suffix . $anchor; |
|
| 488 | + $url .= $suffix.$anchor; |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | // 检测域名 |
| 492 | 492 | $domain = $this->parseDomain($url, $domain); |
| 493 | 493 | |
| 494 | 494 | // URL组装 |
| 495 | - return $domain . rtrim($this->root, '/') . '/' . ltrim($url, '/'); |
|
| 495 | + return $domain.rtrim($this->root, '/').'/'.ltrim($url, '/'); |
|
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | public function __toString() |
@@ -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 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | { |
| 98 | 98 | $target = $this->getTargetFile($directory, $name); |
| 99 | 99 | |
| 100 | - set_error_handler(function ($type, $msg) use (&$error) { |
|
| 100 | + set_error_handler(function($type, $msg) use (&$error) { |
|
| 101 | 101 | $error = $msg; |
| 102 | 102 | }); |
| 103 | 103 | $renamed = rename($this->getPathname(), (string) $target); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | throw new FileException(sprintf('Unable to write in the "%s" directory', $directory)); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - $target = rtrim($directory, '/\\') . \DIRECTORY_SEPARATOR . (null === $name ? $this->getBasename() : $this->getName($name)); |
|
| 130 | + $target = rtrim($directory, '/\\').\DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : $this->getName($name)); |
|
| 131 | 131 | |
| 132 | 132 | return new self($target, false); |
| 133 | 133 | } |
@@ -170,18 +170,18 @@ discard block |
||
| 170 | 170 | switch (true) { |
| 171 | 171 | case in_array($rule, hash_algos()): |
| 172 | 172 | $hash = $this->hash($rule); |
| 173 | - $this->hashName = substr($hash, 0, 2) . DIRECTORY_SEPARATOR . substr($hash, 2); |
|
| 173 | + $this->hashName = substr($hash, 0, 2).DIRECTORY_SEPARATOR.substr($hash, 2); |
|
| 174 | 174 | break; |
| 175 | 175 | case is_callable($rule): |
| 176 | 176 | $this->hashName = call_user_func($rule); |
| 177 | 177 | break; |
| 178 | 178 | default: |
| 179 | - $this->hashName = date('Ymd') . DIRECTORY_SEPARATOR . md5((string) microtime(true)); |
|
| 179 | + $this->hashName = date('Ymd').DIRECTORY_SEPARATOR.md5((string) microtime(true)); |
|
| 180 | 180 | break; |
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - return $this->hashName . '.' . $this->extension(); |
|
| 185 | + return $this->hashName.'.'.$this->extension(); |
|
| 186 | 186 | } |
| 187 | 187 | } |