@@ -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\session\driver; |
| 14 | 14 | |
@@ -62,8 +62,7 @@ discard block |
||
| 62 | 62 | foreach ($hosts as $i => $host) { |
| 63 | 63 | $port = $ports[$i] ?? $ports[0]; |
| 64 | 64 | $this->config['timeout'] > 0 ? |
| 65 | - $this->handler->addServer($host, (int) $port, $this->config['persistent'], 1, $this->config['timeout']) : |
|
| 66 | - $this->handler->addServer($host, (int) $port, $this->config['persistent'], 1); |
|
| 65 | + $this->handler->addServer($host, (int) $port, $this->config['persistent'], 1, $this->config['timeout']) : $this->handler->addServer($host, (int) $port, $this->config['persistent'], 1); |
|
| 67 | 66 | } |
| 68 | 67 | |
| 69 | 68 | return true; |
@@ -77,7 +76,7 @@ discard block |
||
| 77 | 76 | */ |
| 78 | 77 | public function read(string $sessID): string |
| 79 | 78 | { |
| 80 | - return (string) $this->handler->get($this->config['prefix'] . $sessID); |
|
| 79 | + return (string) $this->handler->get($this->config['prefix'].$sessID); |
|
| 81 | 80 | } |
| 82 | 81 | |
| 83 | 82 | /** |
@@ -89,7 +88,7 @@ discard block |
||
| 89 | 88 | */ |
| 90 | 89 | public function write(string $sessID, string $data): bool |
| 91 | 90 | { |
| 92 | - return $this->handler->set($this->config['prefix'] . $sessID, $data, 0, $this->config['expire']); |
|
| 91 | + return $this->handler->set($this->config['prefix'].$sessID, $data, 0, $this->config['expire']); |
|
| 93 | 92 | } |
| 94 | 93 | |
| 95 | 94 | /** |
@@ -100,7 +99,7 @@ discard block |
||
| 100 | 99 | */ |
| 101 | 100 | public function delete(string $sessID): bool |
| 102 | 101 | { |
| 103 | - return $this->handler->delete($this->config['prefix'] . $sessID); |
|
| 102 | + return $this->handler->delete($this->config['prefix'].$sessID); |
|
| 104 | 103 | } |
| 105 | 104 | |
| 106 | 105 | } |
@@ -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\session\driver; |
| 14 | 14 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function read(string $sessID): string |
| 88 | 88 | { |
| 89 | - return (string) $this->handler->get($this->config['prefix'] . $sessID); |
|
| 89 | + return (string) $this->handler->get($this->config['prefix'].$sessID); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | public function write(string $sessID, string $data): bool |
| 100 | 100 | { |
| 101 | 101 | if ($this->config['expire'] > 0) { |
| 102 | - $result = $this->handler->setex($this->config['prefix'] . $sessID, $this->config['expire'], $data); |
|
| 102 | + $result = $this->handler->setex($this->config['prefix'].$sessID, $this->config['expire'], $data); |
|
| 103 | 103 | } else { |
| 104 | - $result = $this->handler->set($this->config['prefix'] . $sessID, $data); |
|
| 104 | + $result = $this->handler->set($this->config['prefix'].$sessID, $data); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | return $result ? true : false; |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | public function delete(string $sessID): bool |
| 117 | 117 | { |
| 118 | - return $this->handler->delete($this->config['prefix'] . $sessID) > 0; |
|
| 118 | + return $this->handler->delete($this->config['prefix'].$sessID) > 0; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | } |
@@ -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\session\driver; |
| 14 | 14 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $this->config = array_merge($this->config, $config); |
| 35 | 35 | |
| 36 | 36 | if (empty($this->config['path'])) { |
| 37 | - $this->config['path'] = $app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . 'session' . DIRECTORY_SEPARATOR; |
|
| 37 | + $this->config['path'] = $app->getRootPath().'runtime'.DIRECTORY_SEPARATOR.'session'.DIRECTORY_SEPARATOR; |
|
| 38 | 38 | } elseif (substr($this->config['path'], -1) != DIRECTORY_SEPARATOR) { |
| 39 | 39 | $this->config['path'] .= DIRECTORY_SEPARATOR; |
| 40 | 40 | } |
@@ -72,11 +72,11 @@ discard block |
||
| 72 | 72 | public function gc() |
| 73 | 73 | { |
| 74 | 74 | $maxlifetime = $this->config['gc_maxlifetime']; |
| 75 | - $list = glob($this->config['path'] . '*'); |
|
| 75 | + $list = glob($this->config['path'].'*'); |
|
| 76 | 76 | |
| 77 | 77 | foreach ($list as $path) { |
| 78 | 78 | if (is_dir($path)) { |
| 79 | - $files = glob($path . DIRECTORY_SEPARATOR . '*.php'); |
|
| 79 | + $files = glob($path.DIRECTORY_SEPARATOR.'*.php'); |
|
| 80 | 80 | foreach ($files as $file) { |
| 81 | 81 | if (time() > filemtime($file) + $maxlifetime) { |
| 82 | 82 | unlink($file); |
@@ -99,12 +99,12 @@ discard block |
||
| 99 | 99 | { |
| 100 | 100 | if ($this->config['prefix']) { |
| 101 | 101 | // 使用子目录 |
| 102 | - $name = $this->config['prefix'] . DIRECTORY_SEPARATOR . 'sess_' . $name; |
|
| 102 | + $name = $this->config['prefix'].DIRECTORY_SEPARATOR.'sess_'.$name; |
|
| 103 | 103 | } else { |
| 104 | - $name = 'sess_' . $name; |
|
| 104 | + $name = 'sess_'.$name; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - $filename = $this->config['path'] . $name . '.php'; |
|
| 107 | + $filename = $this->config['path'].$name.'.php'; |
|
| 108 | 108 | $dir = dirname($filename); |
| 109 | 109 | |
| 110 | 110 | if ($auto && !is_dir($dir)) { |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | $data = gzcompress($data, 3); |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - $data = "<?php\n//" . sprintf('%012d', $expire) . "\n exit();?>\n" . $data; |
|
| 177 | + $data = "<?php\n//".sprintf('%012d', $expire)."\n exit();?>\n".$data; |
|
| 178 | 178 | $result = file_put_contents($filename, $data); |
| 179 | 179 | |
| 180 | 180 | if ($result) { |
@@ -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; |
| 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 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | { |
| 87 | 87 | $target = $this->getTargetFile($directory, $name); |
| 88 | 88 | |
| 89 | - set_error_handler(function ($type, $msg) use (&$error) { |
|
| 89 | + set_error_handler(function($type, $msg) use (&$error) { |
|
| 90 | 90 | $error = $msg; |
| 91 | 91 | }); |
| 92 | 92 | $renamed = rename($this->getPathname(), $target); |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | throw new FileException(sprintf('Unable to write in the "%s" directory', $directory)); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - $target = rtrim($directory, '/\\') . \DIRECTORY_SEPARATOR . (null === $name ? $this->getBasename() : $this->getName($name)); |
|
| 119 | + $target = rtrim($directory, '/\\').\DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : $this->getName($name)); |
|
| 120 | 120 | |
| 121 | 121 | return new self($target, false); |
| 122 | 122 | } |
@@ -159,18 +159,18 @@ discard block |
||
| 159 | 159 | switch (true) { |
| 160 | 160 | case in_array($rule, hash_algos()): |
| 161 | 161 | $hash = $this->hash($rule); |
| 162 | - $this->hashName = substr($hash, 0, 2) . DIRECTORY_SEPARATOR . substr($hash, 2); |
|
| 162 | + $this->hashName = substr($hash, 0, 2).DIRECTORY_SEPARATOR.substr($hash, 2); |
|
| 163 | 163 | break; |
| 164 | 164 | case is_callable($rule): |
| 165 | 165 | $this->hashName = call_user_func($rule); |
| 166 | 166 | break; |
| 167 | 167 | default: |
| 168 | - $this->hashName = date('Ymd') . DIRECTORY_SEPARATOR . md5((string) microtime(true)); |
|
| 168 | + $this->hashName = date('Ymd').DIRECTORY_SEPARATOR.md5((string) microtime(true)); |
|
| 169 | 169 | break; |
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - return $this->hashName . '.' . $this->extension(); |
|
| 174 | + return $this->hashName.'.'.$this->extension(); |
|
| 175 | 175 | } |
| 176 | 176 | } |
@@ -8,7 +8,7 @@ |
||
| 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; |
| 14 | 14 | |
@@ -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\route; |
| 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\route; |
| 14 | 14 | |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | $this->parseUrlParams($array[2], $param); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - return new CallbackDispatch($request, $this, [$namespace . '\\' . App::parseName($class, 1), $method], $param); |
|
| 159 | + return new CallbackDispatch($request, $this, [$namespace.'\\'.App::parseName($class, 1), $method], $param); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $this->parseUrlParams($array[1], $param); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - return new ControllerDispatch($request, $this, $controller . '/' . $action, $param); |
|
| 180 | + return new ControllerDispatch($request, $this, $controller.'/'.$action, $param); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | } |
@@ -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 | |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | { |
| 603 | 603 | if (is_string($route) && isset($option['prefix'])) { |
| 604 | 604 | // 路由地址前缀 |
| 605 | - $route = $option['prefix'] . $route; |
|
| 605 | + $route = $option['prefix'].$route; |
|
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | // 替换路由地址中的变量 |
@@ -610,10 +610,10 @@ discard block |
||
| 610 | 610 | $search = $replace = []; |
| 611 | 611 | |
| 612 | 612 | foreach ($matches as $key => $value) { |
| 613 | - $search[] = '<' . $key . '>'; |
|
| 613 | + $search[] = '<'.$key.'>'; |
|
| 614 | 614 | $replace[] = $value; |
| 615 | 615 | |
| 616 | - $search[] = ':' . $key; |
|
| 616 | + $search[] = ':'.$key; |
|
| 617 | 617 | $replace[] = $value; |
| 618 | 618 | } |
| 619 | 619 | |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | // AJAX PJAX 请求检查 |
| 719 | 719 | foreach (['ajax', 'pjax', 'json'] as $item) { |
| 720 | 720 | if (isset($option[$item])) { |
| 721 | - $call = 'is' . $item; |
|
| 721 | + $call = 'is'.$item; |
|
| 722 | 722 | if ($option[$item] && !$request->$call() || !$option[$item] && $request->$call()) { |
| 723 | 723 | return false; |
| 724 | 724 | } |
@@ -726,8 +726,8 @@ discard block |
||
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | // 伪静态后缀检测 |
| 729 | - if ($request->url() != '/' && ((isset($option['ext']) && false === stripos('|' . $option['ext'] . '|', '|' . $request->ext() . '|')) |
|
| 730 | - || (isset($option['deny_ext']) && false !== stripos('|' . $option['deny_ext'] . '|', '|' . $request->ext() . '|')))) { |
|
| 729 | + if ($request->url() != '/' && ((isset($option['ext']) && false === stripos('|'.$option['ext'].'|', '|'.$request->ext().'|')) |
|
| 730 | + || (isset($option['deny_ext']) && false !== stripos('|'.$option['deny_ext'].'|', '|'.$request->ext().'|')))) { |
|
| 731 | 731 | return false; |
| 732 | 732 | } |
| 733 | 733 | |
@@ -764,7 +764,7 @@ discard block |
||
| 764 | 764 | protected function parseUrlParams(string $url, array &$var = []): void |
| 765 | 765 | { |
| 766 | 766 | if ($url) { |
| 767 | - preg_replace_callback('/(\w+)\|([^\|]+)/', function ($match) use (&$var) { |
|
| 767 | + preg_replace_callback('/(\w+)\|([^\|]+)/', function($match) use (&$var) { |
|
| 768 | 768 | $var[$match[1]] = strip_tags($match[2]); |
| 769 | 769 | }, $url); |
| 770 | 770 | } |
@@ -826,7 +826,7 @@ discard block |
||
| 826 | 826 | $regex .= '\/'; |
| 827 | 827 | } |
| 828 | 828 | |
| 829 | - return $regex . ($completeMatch ? '$' : ''); |
|
| 829 | + return $regex.($completeMatch ? '$' : ''); |
|
| 830 | 830 | } |
| 831 | 831 | |
| 832 | 832 | /** |
@@ -843,7 +843,7 @@ discard block |
||
| 843 | 843 | $slash = substr($name, 0, 1); |
| 844 | 844 | |
| 845 | 845 | if (in_array($slash, ['/', '-'])) { |
| 846 | - $prefix = '\\' . $slash; |
|
| 846 | + $prefix = '\\'.$slash; |
|
| 847 | 847 | $name = substr($name, 1); |
| 848 | 848 | $slash = substr($name, 0, 1); |
| 849 | 849 | } else { |
@@ -851,7 +851,7 @@ discard block |
||
| 851 | 851 | } |
| 852 | 852 | |
| 853 | 853 | if ('<' != $slash) { |
| 854 | - return $prefix . preg_quote($name, '/'); |
|
| 854 | + return $prefix.preg_quote($name, '/'); |
|
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | if (strpos($name, '?')) { |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | $nameRule = $this->router->config('default_route_pattern'); |
| 871 | 871 | } |
| 872 | 872 | |
| 873 | - return '(' . $prefix . '(?<' . $name . $suffix . '>' . $nameRule . '))' . $optional; |
|
| 873 | + return '('.$prefix.'(?<'.$name.$suffix.'>'.$nameRule.'))'.$optional; |
|
| 874 | 874 | } |
| 875 | 875 | |
| 876 | 876 | /** |