@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | protected function getCacheKey($name) |
59 | 59 | { |
60 | - return $this->options['prefix'] . sqlite_escape_string($name); |
|
60 | + return $this->options['prefix'].sqlite_escape_string($name); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | { |
71 | 71 | $name = $this->getCacheKey($name); |
72 | 72 | |
73 | - $sql = 'SELECT value FROM ' . $this->options['table'] . ' WHERE var=\'' . $name . '\' AND (expire=0 OR expire >' . time() . ') LIMIT 1'; |
|
73 | + $sql = 'SELECT value FROM '.$this->options['table'].' WHERE var=\''.$name.'\' AND (expire=0 OR expire >'.time().') LIMIT 1'; |
|
74 | 74 | $result = sqlite_query($this->handler, $sql); |
75 | 75 | |
76 | 76 | return sqlite_num_rows($result); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | |
90 | 90 | $name = $this->getCacheKey($name); |
91 | 91 | |
92 | - $sql = 'SELECT value FROM ' . $this->options['table'] . ' WHERE var=\'' . $name . '\' AND (expire=0 OR expire >' . time() . ') LIMIT 1'; |
|
92 | + $sql = 'SELECT value FROM '.$this->options['table'].' WHERE var=\''.$name.'\' AND (expire=0 OR expire >'.time().') LIMIT 1'; |
|
93 | 93 | |
94 | 94 | $result = sqlite_query($this->handler, $sql); |
95 | 95 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | $tag = ''; |
145 | 145 | } |
146 | 146 | |
147 | - $sql = 'REPLACE INTO ' . $this->options['table'] . ' (var, value, expire, tag) VALUES (\'' . $name . '\', \'' . $value . '\', \'' . $expire . '\', \'' . $tag . '\')'; |
|
147 | + $sql = 'REPLACE INTO '.$this->options['table'].' (var, value, expire, tag) VALUES (\''.$name.'\', \''.$value.'\', \''.$expire.'\', \''.$tag.'\')'; |
|
148 | 148 | |
149 | 149 | if (sqlite_query($this->handler, $sql)) { |
150 | 150 | return true; |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | |
202 | 202 | $name = $this->getCacheKey($name); |
203 | 203 | |
204 | - $sql = 'DELETE FROM ' . $this->options['table'] . ' WHERE var=\'' . $name . '\''; |
|
204 | + $sql = 'DELETE FROM '.$this->options['table'].' WHERE var=\''.$name.'\''; |
|
205 | 205 | sqlite_query($this->handler, $sql); |
206 | 206 | |
207 | 207 | return true; |
@@ -217,14 +217,14 @@ discard block |
||
217 | 217 | { |
218 | 218 | if ($tag) { |
219 | 219 | $name = sqlite_escape_string($this->getTagKey($tag)); |
220 | - $sql = 'DELETE FROM ' . $this->options['table'] . ' WHERE tag=\'' . $name . '\''; |
|
220 | + $sql = 'DELETE FROM '.$this->options['table'].' WHERE tag=\''.$name.'\''; |
|
221 | 221 | sqlite_query($this->handler, $sql); |
222 | 222 | return true; |
223 | 223 | } |
224 | 224 | |
225 | 225 | $this->writeTimes++; |
226 | 226 | |
227 | - $sql = 'DELETE FROM ' . $this->options['table']; |
|
227 | + $sql = 'DELETE FROM '.$this->options['table']; |
|
228 | 228 | |
229 | 229 | sqlite_query($this->handler, $sql); |
230 | 230 |
@@ -55,8 +55,7 @@ discard block |
||
55 | 55 | foreach ((array) $hosts as $i => $host) { |
56 | 56 | $port = isset($ports[$i]) ? $ports[$i] : $ports[0]; |
57 | 57 | $this->options['timeout'] > 0 ? |
58 | - $this->handler->addServer($host, $port, $this->options['persistent'], 1, $this->options['timeout']) : |
|
59 | - $this->handler->addServer($host, $port, $this->options['persistent'], 1); |
|
58 | + $this->handler->addServer($host, $port, $this->options['persistent'], 1, $this->options['timeout']) : $this->handler->addServer($host, $port, $this->options['persistent'], 1); |
|
60 | 59 | } |
61 | 60 | } |
62 | 61 | |
@@ -173,8 +172,7 @@ discard block |
||
173 | 172 | $key = $this->getCacheKey($name); |
174 | 173 | |
175 | 174 | return false === $ttl ? |
176 | - $this->handler->delete($key) : |
|
177 | - $this->handler->delete($key, $ttl); |
|
175 | + $this->handler->delete($key) : $this->handler->delete($key, $ttl); |
|
178 | 176 | } |
179 | 177 | |
180 | 178 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | protected function getCacheKey($name) |
53 | 53 | { |
54 | - return $this->options['path'] . $this->options['prefix'] . md5($name) . '.php'; |
|
54 | + return $this->options['path'].$this->options['prefix'].md5($name).'.php'; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | $first = true; |
124 | 124 | } |
125 | 125 | |
126 | - $ret = file_put_contents($filename, ("<?php return " . var_export($value, true) . ";")); |
|
126 | + $ret = file_put_contents($filename, ("<?php return ".var_export($value, true).";")); |
|
127 | 127 | |
128 | 128 | // 通过设置修改时间实现有效期 |
129 | 129 | if ($ret) { |
@@ -204,6 +204,6 @@ discard block |
||
204 | 204 | |
205 | 205 | $this->writeTimes++; |
206 | 206 | |
207 | - array_map("unlink", glob($this->options['path'] . ($this->options['prefix'] ? $this->options['prefix'] . DIRECTORY_SEPARATOR : '') . '*.php')); |
|
207 | + array_map("unlink", glob($this->options['path'].($this->options['prefix'] ? $this->options['prefix'].DIRECTORY_SEPARATOR : '').'*.php')); |
|
208 | 208 | } |
209 | 209 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | protected function getCacheKey($name) |
140 | 140 | { |
141 | - return $this->options['prefix'] . $name; |
|
141 | + return $this->options['prefix'].$name; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -171,14 +171,14 @@ discard block |
||
171 | 171 | { |
172 | 172 | if (!$this->has($name)) { |
173 | 173 | $time = time(); |
174 | - while ($time + 5 > time() && $this->has($name . '_lock')) { |
|
174 | + while ($time + 5 > time() && $this->has($name.'_lock')) { |
|
175 | 175 | // 存在锁定则等待 |
176 | 176 | usleep(200000); |
177 | 177 | } |
178 | 178 | |
179 | 179 | try { |
180 | 180 | // 锁定 |
181 | - $this->set($name . '_lock', true); |
|
181 | + $this->set($name.'_lock', true); |
|
182 | 182 | |
183 | 183 | if ($value instanceof \Closure) { |
184 | 184 | // 获取缓存数据 |
@@ -189,12 +189,12 @@ discard block |
||
189 | 189 | $this->set($name, $value, $expire); |
190 | 190 | |
191 | 191 | // 解锁 |
192 | - $this->rm($name . '_lock'); |
|
192 | + $this->rm($name.'_lock'); |
|
193 | 193 | } catch (\Exception $e) { |
194 | - $this->rm($name . '_lock'); |
|
194 | + $this->rm($name.'_lock'); |
|
195 | 195 | throw $e; |
196 | 196 | } catch (\throwable $e) { |
197 | - $this->rm($name . '_lock'); |
|
197 | + $this->rm($name.'_lock'); |
|
198 | 198 | throw $e; |
199 | 199 | } |
200 | 200 | } else { |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | |
289 | 289 | protected function getTagKey($tag) |
290 | 290 | { |
291 | - return 'tag_' . md5($tag); |
|
291 | + return 'tag_'.md5($tag); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | /** |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | |
306 | 306 | $serialize = self::$serialize[0]; |
307 | 307 | |
308 | - return self::$serialize[2] . $serialize($data); |
|
308 | + return self::$serialize[2].$serialize($data); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | /** |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | */ |
305 | 305 | public function hasScene($name) |
306 | 306 | { |
307 | - return isset($this->scene[$name]) || method_exists($this, 'scene' . $name); |
|
307 | + return isset($this->scene[$name]) || method_exists($this, 'scene'.$name); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | if (strpos($field, '_confirm')) { |
631 | 631 | $rule = strstr($field, '_confirm', true); |
632 | 632 | } else { |
633 | - $rule = $field . '_confirm'; |
|
633 | + $rule = $field.'_confirm'; |
|
634 | 634 | } |
635 | 635 | } |
636 | 636 | |
@@ -781,9 +781,9 @@ discard block |
||
781 | 781 | if (isset(self::$type[$rule])) { |
782 | 782 | // 注册的验证规则 |
783 | 783 | $result = call_user_func_array(self::$type[$rule], [$value]); |
784 | - } elseif (function_exists('ctype_' . $rule)) { |
|
784 | + } elseif (function_exists('ctype_'.$rule)) { |
|
785 | 785 | // ctype验证规则 |
786 | - $ctypeFun = 'ctype_' . $rule; |
|
786 | + $ctypeFun = 'ctype_'.$rule; |
|
787 | 787 | $result = $ctypeFun($value); |
788 | 788 | } elseif (isset($this->filter[$rule])) { |
789 | 789 | // Filter_var验证规则 |
@@ -1375,7 +1375,7 @@ discard block |
||
1375 | 1375 | |
1376 | 1376 | if (0 !== strpos($rule, '/') && !preg_match('/\/[imsU]{0,4}$/', $rule)) { |
1377 | 1377 | // 不是正则表达式则两端补上/ |
1378 | - $rule = '/^' . $rule . '$/'; |
|
1378 | + $rule = '/^'.$rule.'$/'; |
|
1379 | 1379 | } |
1380 | 1380 | |
1381 | 1381 | return is_scalar($value) && 1 === preg_match($rule, (string) $value); |
@@ -1458,8 +1458,8 @@ discard block |
||
1458 | 1458 | { |
1459 | 1459 | $lang = Container::get('lang'); |
1460 | 1460 | |
1461 | - if (isset($this->message[$attribute . '.' . $type])) { |
|
1462 | - $msg = $this->message[$attribute . '.' . $type]; |
|
1461 | + if (isset($this->message[$attribute.'.'.$type])) { |
|
1462 | + $msg = $this->message[$attribute.'.'.$type]; |
|
1463 | 1463 | } elseif (isset($this->message[$attribute][$type])) { |
1464 | 1464 | $msg = $this->message[$attribute][$type]; |
1465 | 1465 | } elseif (isset($this->message[$attribute])) { |
@@ -1469,7 +1469,7 @@ discard block |
||
1469 | 1469 | } elseif (0 === strpos($type, 'require')) { |
1470 | 1470 | $msg = self::$typeMsg['require']; |
1471 | 1471 | } else { |
1472 | - $msg = $title . $lang->get('not conform to the rules'); |
|
1472 | + $msg = $title.$lang->get('not conform to the rules'); |
|
1473 | 1473 | } |
1474 | 1474 | |
1475 | 1475 | if (!is_string($msg)) { |
@@ -1520,8 +1520,8 @@ discard block |
||
1520 | 1520 | return; |
1521 | 1521 | } |
1522 | 1522 | |
1523 | - if (method_exists($this, 'scene' . $scene)) { |
|
1524 | - call_user_func([$this, 'scene' . $scene]); |
|
1523 | + if (method_exists($this, 'scene'.$scene)) { |
|
1524 | + call_user_func([$this, 'scene'.$scene]); |
|
1525 | 1525 | } elseif (isset($this->scene[$scene])) { |
1526 | 1526 | // 如果设置了验证适用场景 |
1527 | 1527 | $scene = $this->scene[$scene]; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public static function create($data = '', $type = '', $code = 200, array $header = [], $options = []) |
106 | 106 | { |
107 | - $class = false !== strpos($type, '\\') ? $type : '\\think\\response\\' . ucfirst(strtolower($type)); |
|
107 | + $class = false !== strpos($type, '\\') ? $type : '\\think\\response\\'.ucfirst(strtolower($type)); |
|
108 | 108 | |
109 | 109 | if (class_exists($class)) { |
110 | 110 | return new $class($data, $code, $header, $options); |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | if (200 == $this->code && $this->allowCache) { |
136 | 136 | $cache = $this->app['request']->getCache(); |
137 | 137 | if ($cache) { |
138 | - $this->header['Cache-Control'] = 'max-age=' . $cache[1] . ',must-revalidate'; |
|
139 | - $this->header['Last-Modified'] = gmdate('D, d M Y H:i:s') . ' GMT'; |
|
140 | - $this->header['Expires'] = gmdate('D, d M Y H:i:s', $_SERVER['REQUEST_TIME'] + $cache[1]) . ' GMT'; |
|
138 | + $this->header['Cache-Control'] = 'max-age='.$cache[1].',must-revalidate'; |
|
139 | + $this->header['Last-Modified'] = gmdate('D, d M Y H:i:s').' GMT'; |
|
140 | + $this->header['Expires'] = gmdate('D, d M Y H:i:s', $_SERVER['REQUEST_TIME'] + $cache[1]).' GMT'; |
|
141 | 141 | |
142 | 142 | $this->app['cache']->tag($cache[2])->set($cache[0], [$data, $this->header], $cache[1]); |
143 | 143 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | http_response_code($this->code); |
149 | 149 | // 发送头部信息 |
150 | 150 | foreach ($this->header as $name => $val) { |
151 | - header($name . (!is_null($val) ? ':' . $val : '')); |
|
151 | + header($name.(!is_null($val) ? ':'.$val : '')); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | */ |
356 | 356 | public function contentType($contentType, $charset = 'utf-8') |
357 | 357 | { |
358 | - $this->header['Content-Type'] = $contentType . '; charset=' . $charset; |
|
358 | + $this->header['Content-Type'] = $contentType.'; charset='.$charset; |
|
359 | 359 | |
360 | 360 | return $this; |
361 | 361 | } |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | $config = $this->config; |
103 | 103 | } |
104 | 104 | |
105 | - $name = $config['prefix'] . $name; |
|
105 | + $name = $config['prefix'].$name; |
|
106 | 106 | |
107 | 107 | // 设置cookie |
108 | 108 | if (is_array($value)) { |
109 | 109 | array_walk_recursive($value, [$this, 'jsonFormatProtect'], 'encode'); |
110 | - $value = 'think:' . json_encode($value); |
|
110 | + $value = 'think:'.json_encode($value); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | $expire = !empty($config['expire']) ? $_SERVER['REQUEST_TIME'] + intval($config['expire']) : 0; |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | public function has($name, $prefix = null) |
163 | 163 | { |
164 | 164 | $prefix = !is_null($prefix) ? $prefix : $this->config['prefix']; |
165 | - $name = $prefix . $name; |
|
165 | + $name = $prefix.$name; |
|
166 | 166 | |
167 | 167 | return isset($_COOKIE[$name]); |
168 | 168 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | public function get($name = '', $prefix = null) |
178 | 178 | { |
179 | 179 | $prefix = !is_null($prefix) ? $prefix : $this->config['prefix']; |
180 | - $key = $prefix . $name; |
|
180 | + $key = $prefix.$name; |
|
181 | 181 | |
182 | 182 | if ('' == $name) { |
183 | 183 | if ($prefix) { |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | { |
217 | 217 | $config = $this->config; |
218 | 218 | $prefix = !is_null($prefix) ? $prefix : $config['prefix']; |
219 | - $name = $prefix . $name; |
|
219 | + $name = $prefix.$name; |
|
220 | 220 | |
221 | 221 | if ($config['setcookie']) { |
222 | 222 | $this->setcookie($name, '', $_SERVER['REQUEST_TIME'] - 3600, $config); |
@@ -213,7 +213,7 @@ |
||
213 | 213 | $options = $this->options; |
214 | 214 | |
215 | 215 | $arguments = array_merge($this->prefix, $this->arguments); |
216 | - $script = implode(' ', array_map([__NAMESPACE__ . '\\Utils', 'escapeArgument'], $arguments)); |
|
216 | + $script = implode(' ', array_map([__NAMESPACE__.'\\Utils', 'escapeArgument'], $arguments)); |
|
217 | 217 | |
218 | 218 | if ($this->inheritEnv) { |
219 | 219 | // include $_ENV for BC purposes |
@@ -24,7 +24,7 @@ |
||
24 | 24 | throw new \InvalidArgumentException('Expected a failed process, but the given process was successful.'); |
25 | 25 | } |
26 | 26 | |
27 | - $error = sprintf('The command "%s" failed.' . "\nExit Code: %s(%s)", $process->getCommandLine(), $process->getExitCode(), $process->getExitCodeText()); |
|
27 | + $error = sprintf('The command "%s" failed.'."\nExit Code: %s(%s)", $process->getCommandLine(), $process->getExitCode(), $process->getExitCodeText()); |
|
28 | 28 | |
29 | 29 | if (!$process->isOutputDisabled()) { |
30 | 30 | $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s", $process->getOutput(), $process->getErrorOutput()); |