@@ -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()); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | $escapedArgument .= '\\"'; |
31 | 31 | } elseif (self::isSurroundedBy($part, '%')) { |
32 | 32 | // Avoid environment variable expansion |
33 | - $escapedArgument .= '^%"' . substr($part, 1, -1) . '"^%'; |
|
33 | + $escapedArgument .= '^%"'.substr($part, 1, -1).'"^%'; |
|
34 | 34 | } else { |
35 | 35 | // escape trailing backslash |
36 | 36 | if ('\\' === substr($part, -1)) { |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | } |
42 | 42 | } |
43 | 43 | if ($quote) { |
44 | - $escapedArgument = '"' . $escapedArgument . '"'; |
|
44 | + $escapedArgument = '"'.$escapedArgument.'"'; |
|
45 | 45 | } |
46 | 46 | return $escapedArgument; |
47 | 47 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | public function toArray() |
49 | 49 | { |
50 | - return array_map(function ($value) { |
|
50 | + return array_map(function($value) { |
|
51 | 51 | return ($value instanceof Model || $value instanceof self) ? $value->toArray() : $value; |
52 | 52 | }, $this->items); |
53 | 53 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | $operator = '='; |
345 | 345 | } |
346 | 346 | |
347 | - return $this->filter(function ($data) use ($field, $operator, $value) { |
|
347 | + return $this->filter(function($data) use ($field, $operator, $value) { |
|
348 | 348 | if (strpos($field, '.')) { |
349 | 349 | list($field, $relation) = explode('.', $field); |
350 | 350 | |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | { |
415 | 415 | $items = $this->items; |
416 | 416 | |
417 | - $callback = $callback ?: function ($a, $b) { |
|
417 | + $callback = $callback ?: function($a, $b) { |
|
418 | 418 | return $a == $b ? 0 : (($a < $b) ? -1 : 1); |
419 | 419 | |
420 | 420 | }; |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | */ |
435 | 435 | public function order($field, $order = null, $intSort = true) |
436 | 436 | { |
437 | - return $this->sort(function ($a, $b) use ($field, $order, $intSort) { |
|
437 | + return $this->sort(function($a, $b) use ($field, $order, $intSort) { |
|
438 | 438 | $fieldA = isset($a[$field]) ? $a[$field] : null; |
439 | 439 | $fieldB = isset($b[$field]) ? $b[$field] : null; |
440 | 440 |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | |
151 | 151 | $url = $path; |
152 | 152 | if (!empty($parameters)) { |
153 | - $url .= '?' . http_build_query($parameters, null, '&'); |
|
153 | + $url .= '?'.http_build_query($parameters, null, '&'); |
|
154 | 154 | } |
155 | 155 | |
156 | - return $url . $this->buildFragment(); |
|
156 | + return $url.$this->buildFragment(); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | */ |
289 | 289 | protected function buildFragment() |
290 | 290 | { |
291 | - return $this->options['fragment'] ? '#' . $this->options['fragment'] : ''; |
|
291 | + return $this->options['fragment'] ? '#'.$this->options['fragment'] : ''; |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | /** |