@@ -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\log\driver; |
14 | 14 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | if (empty($this->config['path'])) { |
51 | - $this->config['path'] = $app->getRuntimePath() . 'log'; |
|
51 | + $this->config['path'] = $app->getRuntimePath().'log'; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | if (substr($this->config['path'], -1) != DIRECTORY_SEPARATOR) { |
@@ -82,8 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | $message[] = $this->config['json'] ? |
85 | - json_encode(['time' => $time, 'type' => $type, 'msg' => $msg], $this->config['json_options']) : |
|
86 | - sprintf($this->config['format'], $time, $type, $msg); |
|
85 | + json_encode(['time' => $time, 'type' => $type, 'msg' => $msg], $this->config['json_options']) : sprintf($this->config['format'], $time, $type, $msg); |
|
87 | 86 | } |
88 | 87 | |
89 | 88 | if (true === $this->config['apart_level'] || in_array($type, $this->config['apart_level'])) { |
@@ -121,7 +120,7 @@ discard block |
||
121 | 120 | $info[$type] = is_array($msg) ? implode(PHP_EOL, $msg) : $msg; |
122 | 121 | } |
123 | 122 | |
124 | - $message = implode(PHP_EOL, $info) . PHP_EOL; |
|
123 | + $message = implode(PHP_EOL, $info).PHP_EOL; |
|
125 | 124 | |
126 | 125 | return error_log($message, 3, $destination); |
127 | 126 | } |
@@ -134,7 +133,7 @@ discard block |
||
134 | 133 | protected function getMasterLogFile(): string |
135 | 134 | { |
136 | 135 | if ($this->config['max_files']) { |
137 | - $files = glob($this->config['path'] . '*.log'); |
|
136 | + $files = glob($this->config['path'].'*.log'); |
|
138 | 137 | |
139 | 138 | try { |
140 | 139 | if (count($files) > $this->config['max_files']) { |
@@ -147,15 +146,15 @@ discard block |
||
147 | 146 | |
148 | 147 | if ($this->config['single']) { |
149 | 148 | $name = is_string($this->config['single']) ? $this->config['single'] : 'single'; |
150 | - $destination = $this->config['path'] . $name . '.log'; |
|
149 | + $destination = $this->config['path'].$name.'.log'; |
|
151 | 150 | } else { |
152 | 151 | if ($this->config['max_files']) { |
153 | - $filename = date('Ymd') . '.log'; |
|
152 | + $filename = date('Ymd').'.log'; |
|
154 | 153 | } else { |
155 | - $filename = date('Ym') . DIRECTORY_SEPARATOR . date('d') . '.log'; |
|
154 | + $filename = date('Ym').DIRECTORY_SEPARATOR.date('d').'.log'; |
|
156 | 155 | } |
157 | 156 | |
158 | - $destination = $this->config['path'] . $filename; |
|
157 | + $destination = $this->config['path'].$filename; |
|
159 | 158 | } |
160 | 159 | |
161 | 160 | return $destination; |
@@ -173,14 +172,14 @@ discard block |
||
173 | 172 | if ($this->config['single']) { |
174 | 173 | $name = is_string($this->config['single']) ? $this->config['single'] : 'single'; |
175 | 174 | |
176 | - $name .= '_' . $type; |
|
175 | + $name .= '_'.$type; |
|
177 | 176 | } elseif ($this->config['max_files']) { |
178 | - $name = date('Ymd') . '_' . $type; |
|
177 | + $name = date('Ymd').'_'.$type; |
|
179 | 178 | } else { |
180 | - $name = date('d') . '_' . $type; |
|
179 | + $name = date('d').'_'.$type; |
|
181 | 180 | } |
182 | 181 | |
183 | - return $path . DIRECTORY_SEPARATOR . $name . '.log'; |
|
182 | + return $path.DIRECTORY_SEPARATOR.$name.'.log'; |
|
184 | 183 | } |
185 | 184 | |
186 | 185 | /** |
@@ -193,7 +192,7 @@ discard block |
||
193 | 192 | { |
194 | 193 | if (is_file($destination) && floor($this->config['file_size']) <= filesize($destination)) { |
195 | 194 | try { |
196 | - rename($destination, dirname($destination) . DIRECTORY_SEPARATOR . time() . '-' . basename($destination)); |
|
195 | + rename($destination, dirname($destination).DIRECTORY_SEPARATOR.time().'-'.basename($destination)); |
|
197 | 196 | } catch (\Exception $e) { |
198 | 197 | // |
199 | 198 | } |
@@ -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\contract; |
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\cache; |
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\cache; |
14 | 14 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function getCacheKey(string $name): string |
87 | 87 | { |
88 | - return $this->options['prefix'] . $name; |
|
88 | + return $this->options['prefix'].$name; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | |
147 | 147 | $time = time(); |
148 | 148 | |
149 | - while ($time + 5 > time() && $this->has($name . '_lock')) { |
|
149 | + while ($time + 5 > time() && $this->has($name.'_lock')) { |
|
150 | 150 | // 存在锁定则等待 |
151 | 151 | usleep(200000); |
152 | 152 | } |
153 | 153 | |
154 | 154 | try { |
155 | 155 | // 锁定 |
156 | - $this->set($name . '_lock', true); |
|
156 | + $this->set($name.'_lock', true); |
|
157 | 157 | |
158 | 158 | if ($value instanceof Closure) { |
159 | 159 | // 获取缓存数据 |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | $this->set($name, $value, $expire); |
165 | 165 | |
166 | 166 | // 解锁 |
167 | - $this->delete($name . '_lock'); |
|
167 | + $this->delete($name.'_lock'); |
|
168 | 168 | } catch (Exception | throwable $e) { |
169 | - $this->delete($name . '_lock'); |
|
169 | + $this->delete($name.'_lock'); |
|
170 | 170 | throw $e; |
171 | 171 | } |
172 | 172 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | $key = implode('-', $name); |
186 | 186 | |
187 | 187 | if (!isset($this->tag[$key])) { |
188 | - $name = array_map(function ($val) { |
|
188 | + $name = array_map(function($val) { |
|
189 | 189 | return $this->getTagKey($val); |
190 | 190 | }, $name); |
191 | 191 | $this->tag[$key] = new TagSet($name, $this); |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | */ |
214 | 214 | public function getTagKey(string $tag): string |
215 | 215 | { |
216 | - return $this->options['tag_prefix'] . md5($tag); |
|
216 | + return $this->options['tag_prefix'].md5($tag); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -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\cache\driver; |
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\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 | |
@@ -191,8 +191,7 @@ discard block |
||
191 | 191 | $key = $this->getCacheKey($name); |
192 | 192 | |
193 | 193 | return false === $ttl ? |
194 | - $this->handler->delete($key) : |
|
195 | - $this->handler->delete($key, $ttl); |
|
194 | + $this->handler->delete($key) : $this->handler->delete($key, $ttl); |
|
196 | 195 | } |
197 | 196 | |
198 | 197 | /** |
@@ -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 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | if (empty($this->options['path'])) { |
51 | - $this->options['path'] = $app->getRuntimePath() . 'cache'; |
|
51 | + $this->options['path'] = $app->getRuntimePath().'cache'; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | if (substr($this->options['path'], -1) != DIRECTORY_SEPARATOR) { |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | |
69 | 69 | if ($this->options['cache_subdir']) { |
70 | 70 | // 使用子目录 |
71 | - $name = substr($name, 0, 2) . DIRECTORY_SEPARATOR . substr($name, 2); |
|
71 | + $name = substr($name, 0, 2).DIRECTORY_SEPARATOR.substr($name, 2); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | if ($this->options['prefix']) { |
75 | - $name = $this->options['prefix'] . DIRECTORY_SEPARATOR . $name; |
|
75 | + $name = $this->options['prefix'].DIRECTORY_SEPARATOR.$name; |
|
76 | 76 | } |
77 | 77 | |
78 | - return $this->options['path'] . $name . '.php'; |
|
78 | + return $this->options['path'].$name.'.php'; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | $data = gzcompress($data, 3); |
176 | 176 | } |
177 | 177 | |
178 | - $data = "<?php\n//" . sprintf('%012d', $expire) . "\n exit();?>\n" . $data; |
|
178 | + $data = "<?php\n//".sprintf('%012d', $expire)."\n exit();?>\n".$data; |
|
179 | 179 | $result = file_put_contents($filename, $data); |
180 | 180 | |
181 | 181 | if ($result) { |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | { |
241 | 241 | $this->writeTimes++; |
242 | 242 | |
243 | - $dirname = $this->options['path'] . $this->options['prefix']; |
|
243 | + $dirname = $this->options['path'].$this->options['prefix']; |
|
244 | 244 | |
245 | 245 | $this->rmdir($dirname); |
246 | 246 |
@@ -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 | /** |