@@ -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\db; |
14 | 14 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function getBuilderClass(): string |
138 | 138 | { |
139 | - return $this->getConfig('builder') ?: '\\think\\db\\builder\\' . ucfirst($this->getConfig('type')); |
|
139 | + return $this->getConfig('builder') ?: '\\think\\db\\builder\\'.ucfirst($this->getConfig('type')); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -246,14 +246,14 @@ discard block |
||
246 | 246 | list($tableName) = explode(' ', $tableName); |
247 | 247 | |
248 | 248 | if (!strpos($tableName, '.')) { |
249 | - $schema = $this->getConfig('database') . '.' . $tableName; |
|
249 | + $schema = $this->getConfig('database').'.'.$tableName; |
|
250 | 250 | } else { |
251 | 251 | $schema = $tableName; |
252 | 252 | } |
253 | 253 | |
254 | 254 | if (!isset($this->info[$schema])) { |
255 | 255 | // 读取缓存 |
256 | - $cacheFile = Container::pull('app')->getRuntimePath() . 'schema' . DIRECTORY_SEPARATOR . $schema . '.php'; |
|
256 | + $cacheFile = Container::pull('app')->getRuntimePath().'schema'.DIRECTORY_SEPARATOR.$schema.'.php'; |
|
257 | 257 | |
258 | 258 | if (!$this->config['debug'] && is_file($cacheFile)) { |
259 | 259 | $info = include $cacheFile; |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | $fields = array_keys($info); |
265 | - $bind = $type = []; |
|
265 | + $bind = $type = []; |
|
266 | 266 | |
267 | 267 | foreach ($info as $key => $val) { |
268 | 268 | // 记录字段类型 |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | $startTime = microtime(true); |
382 | 382 | $this->links[$linkNum] = $this->createPdo($config['dsn'], $config['username'], $config['password'], $params); |
383 | 383 | // 记录数据库连接信息 |
384 | - $this->log('[ DB ] CONNECT:[ UseTime:' . number_format(microtime(true) - $startTime, 6) . 's ] ' . $config['dsn']); |
|
384 | + $this->log('[ DB ] CONNECT:[ UseTime:'.number_format(microtime(true) - $startTime, 6).'s ] '.$config['dsn']); |
|
385 | 385 | |
386 | 386 | return $this->links[$linkNum]; |
387 | 387 | } catch (\PDOException $e) { |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | |
644 | 644 | if (!$result) { |
645 | 645 | // 执行查询 |
646 | - $resultSet = $this->query($query, function ($query) { |
|
646 | + $resultSet = $this->query($query, function($query) { |
|
647 | 647 | return $this->builder->select($query, true); |
648 | 648 | }); |
649 | 649 | |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | |
689 | 689 | if (!$resultSet) { |
690 | 690 | // 执行查询操作 |
691 | - $resultSet = $this->query($query, function ($query) { |
|
691 | + $resultSet = $this->query($query, function($query) { |
|
692 | 692 | return $this->builder->select($query); |
693 | 693 | }); |
694 | 694 | } |
@@ -921,7 +921,7 @@ discard block |
||
921 | 921 | list($distinct, $field) = explode(' ', $field); |
922 | 922 | } |
923 | 923 | |
924 | - $field = $aggregate . '(' . (!empty($distinct) ? 'DISTINCT ' : '') . $this->builder->parseKey($query, $field, true) . ') AS tp_' . strtolower($aggregate); |
|
924 | + $field = $aggregate.'('.(!empty($distinct) ? 'DISTINCT ' : '').$this->builder->parseKey($query, $field, true).') AS tp_'.strtolower($aggregate); |
|
925 | 925 | |
926 | 926 | $result = $this->value($query, $field, 0, false); |
927 | 927 | |
@@ -945,7 +945,7 @@ discard block |
||
945 | 945 | } |
946 | 946 | |
947 | 947 | if ($key && '*' != $column) { |
948 | - $field = $key . ',' . $column; |
|
948 | + $field = $key.','.$column; |
|
949 | 949 | } else { |
950 | 950 | $field = $column; |
951 | 951 | } |
@@ -1016,15 +1016,14 @@ discard block |
||
1016 | 1016 | $type = is_array($val) ? $val[1] : PDO::PARAM_STR; |
1017 | 1017 | |
1018 | 1018 | if ((self::PARAM_FLOAT == $type || PDO::PARAM_STR == $type) && is_string($value)) { |
1019 | - $value = '\'' . addslashes($value) . '\''; |
|
1019 | + $value = '\''.addslashes($value).'\''; |
|
1020 | 1020 | } elseif (PDO::PARAM_INT == $type && '' === $value) { |
1021 | 1021 | $value = 0; |
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | // 判断占位符 |
1025 | 1025 | $sql = is_numeric($key) ? |
1026 | - substr_replace($sql, $value, strpos($sql, '?'), 1) : |
|
1027 | - substr_replace($sql, $value, strpos($sql, ':' . $key), strlen(':' . $key)); |
|
1026 | + substr_replace($sql, $value, strpos($sql, '?'), 1) : substr_replace($sql, $value, strpos($sql, ':'.$key), strlen(':'.$key)); |
|
1028 | 1027 | } |
1029 | 1028 | |
1030 | 1029 | return rtrim($sql); |
@@ -1043,7 +1042,7 @@ discard block |
||
1043 | 1042 | { |
1044 | 1043 | foreach ($bind as $key => $val) { |
1045 | 1044 | // 占位符 |
1046 | - $param = is_numeric($key) ? $key + 1 : ':' . $key; |
|
1045 | + $param = is_numeric($key) ? $key + 1 : ':'.$key; |
|
1047 | 1046 | |
1048 | 1047 | if (is_array($val)) { |
1049 | 1048 | if (PDO::PARAM_INT == $val[1] && '' === $val[0]) { |
@@ -1079,7 +1078,7 @@ discard block |
||
1079 | 1078 | protected function bindParam(array $bind): void |
1080 | 1079 | { |
1081 | 1080 | foreach ($bind as $key => $val) { |
1082 | - $param = is_numeric($key) ? $key + 1 : ':' . $key; |
|
1081 | + $param = is_numeric($key) ? $key + 1 : ':'.$key; |
|
1083 | 1082 | |
1084 | 1083 | if (is_array($val)) { |
1085 | 1084 | array_unshift($val, $param); |
@@ -1187,7 +1186,7 @@ discard block |
||
1187 | 1186 | $this->linkID->beginTransaction(); |
1188 | 1187 | } elseif ($this->transTimes > 1 && $this->supportSavepoint()) { |
1189 | 1188 | $this->linkID->exec( |
1190 | - $this->parseSavepoint('trans' . $this->transTimes) |
|
1189 | + $this->parseSavepoint('trans'.$this->transTimes) |
|
1191 | 1190 | ); |
1192 | 1191 | } |
1193 | 1192 | } catch (\Exception $e) { |
@@ -1230,7 +1229,7 @@ discard block |
||
1230 | 1229 | $this->linkID->rollBack(); |
1231 | 1230 | } elseif ($this->transTimes > 1 && $this->supportSavepoint()) { |
1232 | 1231 | $this->linkID->exec( |
1233 | - $this->parseSavepointRollBack('trans' . $this->transTimes) |
|
1232 | + $this->parseSavepointRollBack('trans'.$this->transTimes) |
|
1234 | 1233 | ); |
1235 | 1234 | } |
1236 | 1235 | |
@@ -1254,7 +1253,7 @@ discard block |
||
1254 | 1253 | */ |
1255 | 1254 | protected function parseSavepoint(string $name): string |
1256 | 1255 | { |
1257 | - return 'SAVEPOINT ' . $name; |
|
1256 | + return 'SAVEPOINT '.$name; |
|
1258 | 1257 | } |
1259 | 1258 | |
1260 | 1259 | /** |
@@ -1265,7 +1264,7 @@ discard block |
||
1265 | 1264 | */ |
1266 | 1265 | protected function parseSavepointRollBack(string $name): string |
1267 | 1266 | { |
1268 | - return 'ROLLBACK TO SAVEPOINT ' . $name; |
|
1267 | + return 'ROLLBACK TO SAVEPOINT '.$name; |
|
1269 | 1268 | } |
1270 | 1269 | |
1271 | 1270 | /** |
@@ -1376,13 +1375,13 @@ discard block |
||
1376 | 1375 | { |
1377 | 1376 | if ($this->PDOStatement) { |
1378 | 1377 | $error = $this->PDOStatement->errorInfo(); |
1379 | - $error = $error[1] . ':' . $error[2]; |
|
1378 | + $error = $error[1].':'.$error[2]; |
|
1380 | 1379 | } else { |
1381 | 1380 | $error = ''; |
1382 | 1381 | } |
1383 | 1382 | |
1384 | 1383 | if ('' != $this->queryStr) { |
1385 | - $error .= "\n [ SQL语句 ] : " . $this->getLastsql(); |
|
1384 | + $error .= "\n [ SQL语句 ] : ".$this->getLastsql(); |
|
1386 | 1385 | } |
1387 | 1386 | |
1388 | 1387 | return $error; |
@@ -1446,10 +1445,10 @@ discard block |
||
1446 | 1445 | } |
1447 | 1446 | |
1448 | 1447 | // 未注册监听则记录到日志中 |
1449 | - $this->log('[ SQL ] ' . $sql . ' [ ' . $master . 'RunTime:' . $runtime . 's ]'); |
|
1448 | + $this->log('[ SQL ] '.$sql.' [ '.$master.'RunTime:'.$runtime.'s ]'); |
|
1450 | 1449 | |
1451 | 1450 | if (!empty($explain)) { |
1452 | - $this->log('[ EXPLAIN : ' . var_export($explain, true) . ' ]'); |
|
1451 | + $this->log('[ EXPLAIN : '.var_export($explain, true).' ]'); |
|
1453 | 1452 | } |
1454 | 1453 | } |
1455 | 1454 | } |
@@ -1551,9 +1550,9 @@ discard block |
||
1551 | 1550 | } else { |
1552 | 1551 | if (true === $key) { |
1553 | 1552 | if (!empty($query->getOptions('key'))) { |
1554 | - $key = 'think:' . $this->getConfig('database') . '.' . $query->getTable() . '|' . $query->getOptions('key'); |
|
1553 | + $key = 'think:'.$this->getConfig('database').'.'.$query->getTable().'|'.$query->getOptions('key'); |
|
1555 | 1554 | } else { |
1556 | - $key = md5($this->getConfig('database') . serialize($query->getOptions()) . serialize($query->getBind(false))); |
|
1555 | + $key = md5($this->getConfig('database').serialize($query->getOptions()).serialize($query->getBind(false))); |
|
1557 | 1556 | } |
1558 | 1557 | } |
1559 | 1558 |
@@ -1812,9 +1812,11 @@ |
||
1812 | 1812 | |
1813 | 1813 | if ($this->config['rw_separate']) { |
1814 | 1814 | // 主从式采用读写分离 |
1815 | - if ($master) // 主服务器写入 |
|
1815 | + if ($master) { |
|
1816 | + // 主服务器写入 |
|
1816 | 1817 | { |
1817 | 1818 | $r = $m; |
1819 | + } |
|
1818 | 1820 | } elseif (is_numeric($this->config['slave_no'])) { |
1819 | 1821 | // 指定服务器读 |
1820 | 1822 | $r = $this->config['slave_no']; |
@@ -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 | |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | */ |
366 | 366 | public function hasScene(string $name): bool |
367 | 367 | { |
368 | - return isset($this->scene[$name]) || method_exists($this, 'scene' . $name); |
|
368 | + return isset($this->scene[$name]) || method_exists($this, 'scene'.$name); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | /** |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | if (strpos($field, '_confirm')) { |
718 | 718 | $rule = strstr($field, '_confirm', true); |
719 | 719 | } else { |
720 | - $rule = $field . '_confirm'; |
|
720 | + $rule = $field.'_confirm'; |
|
721 | 721 | } |
722 | 722 | } |
723 | 723 | |
@@ -868,9 +868,9 @@ discard block |
||
868 | 868 | if (isset($this->type[$rule])) { |
869 | 869 | // 注册的验证规则 |
870 | 870 | $result = call_user_func_array($this->type[$rule], [$value]); |
871 | - } elseif (function_exists('ctype_' . $rule)) { |
|
871 | + } elseif (function_exists('ctype_'.$rule)) { |
|
872 | 872 | // ctype验证规则 |
873 | - $ctypeFun = 'ctype_' . $rule; |
|
873 | + $ctypeFun = 'ctype_'.$rule; |
|
874 | 874 | $result = $ctypeFun($value); |
875 | 875 | } elseif (isset($this->filter[$rule])) { |
876 | 876 | // Filter_var验证规则 |
@@ -1508,7 +1508,7 @@ discard block |
||
1508 | 1508 | |
1509 | 1509 | if (is_string($rule) && 0 !== strpos($rule, '/') && !preg_match('/\/[imsU]{0,4}$/', $rule)) { |
1510 | 1510 | // 不是正则表达式则两端补上/ |
1511 | - $rule = '/^' . $rule . '$/'; |
|
1511 | + $rule = '/^'.$rule.'$/'; |
|
1512 | 1512 | } |
1513 | 1513 | |
1514 | 1514 | return is_scalar($value) && 1 === preg_match($rule, (string) $value); |
@@ -1558,8 +1558,8 @@ discard block |
||
1558 | 1558 | */ |
1559 | 1559 | protected function getRuleMsg(string $attribute, string $title, string $type, $rule): string |
1560 | 1560 | { |
1561 | - if (isset($this->message[$attribute . '.' . $type])) { |
|
1562 | - $msg = $this->message[$attribute . '.' . $type]; |
|
1561 | + if (isset($this->message[$attribute.'.'.$type])) { |
|
1562 | + $msg = $this->message[$attribute.'.'.$type]; |
|
1563 | 1563 | } elseif (isset($this->message[$attribute][$type])) { |
1564 | 1564 | $msg = $this->message[$attribute][$type]; |
1565 | 1565 | } elseif (isset($this->message[$attribute])) { |
@@ -1569,7 +1569,7 @@ discard block |
||
1569 | 1569 | } elseif (0 === strpos($type, 'require')) { |
1570 | 1570 | $msg = $this->typeMsg['require']; |
1571 | 1571 | } else { |
1572 | - $msg = $title . $this->lang->get('not conform to the rules'); |
|
1572 | + $msg = $title.$this->lang->get('not conform to the rules'); |
|
1573 | 1573 | } |
1574 | 1574 | |
1575 | 1575 | if (!is_string($msg)) { |
@@ -1613,8 +1613,8 @@ discard block |
||
1613 | 1613 | { |
1614 | 1614 | $this->only = $this->append = $this->remove = []; |
1615 | 1615 | |
1616 | - if (method_exists($this, 'scene' . $scene)) { |
|
1617 | - call_user_func([$this, 'scene' . $scene]); |
|
1616 | + if (method_exists($this, 'scene'.$scene)) { |
|
1617 | + call_user_func([$this, 'scene'.$scene]); |
|
1618 | 1618 | } elseif (isset($this->scene[$scene])) { |
1619 | 1619 | // 如果设置了验证适用场景 |
1620 | 1620 | $this->only = $this->scene[$scene]; |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: yangweijie <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | namespace think\debug; |
13 | 13 | |
14 | 14 | use think\App; |
@@ -52,21 +52,21 @@ discard block |
||
52 | 52 | $mem = number_format((memory_get_usage() - $app->getBeginMem()) / 1024, 2); |
53 | 53 | |
54 | 54 | if ($request->host()) { |
55 | - $uri = $request->protocol() . ' ' . $request->method() . ' : ' . $request->url(true); |
|
55 | + $uri = $request->protocol().' '.$request->method().' : '.$request->url(true); |
|
56 | 56 | } else { |
57 | - $uri = 'cmd:' . implode(' ', $_SERVER['argv']); |
|
57 | + $uri = 'cmd:'.implode(' ', $_SERVER['argv']); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | // 页面Trace信息 |
61 | 61 | $base = [ |
62 | - '请求信息' => date('Y-m-d H:i:s', $request->time()) . ' ' . $uri, |
|
63 | - '运行时间' => number_format((float) $runtime, 6) . 's [ 吞吐率:' . $reqs . 'req/s ] 内存消耗:' . $mem . 'kb 文件加载:' . count(get_included_files()), |
|
64 | - '查询信息' => $app->db->getQueryTimes() . ' queries', |
|
65 | - '缓存信息' => $app->cache->getReadTimes() . ' reads,' . $app->cache->getWriteTimes() . ' writes', |
|
62 | + '请求信息' => date('Y-m-d H:i:s', $request->time()).' '.$uri, |
|
63 | + '运行时间' => number_format((float) $runtime, 6).'s [ 吞吐率:'.$reqs.'req/s ] 内存消耗:'.$mem.'kb 文件加载:'.count(get_included_files()), |
|
64 | + '查询信息' => $app->db->getQueryTimes().' queries', |
|
65 | + '缓存信息' => $app->cache->getReadTimes().' reads,'.$app->cache->getWriteTimes().' writes', |
|
66 | 66 | ]; |
67 | 67 | |
68 | 68 | if ($app->session->getId(false)) { |
69 | - $base['会话信息'] = 'SESSION_ID=' . $app->session->getId(); |
|
69 | + $base['会话信息'] = 'SESSION_ID='.$app->session->getId(); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | $info = $this->getFileInfo(); |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | case '调试': |
126 | 126 | $var_type = gettype($m); |
127 | 127 | if (in_array($var_type, ['array', 'string'])) { |
128 | - $line[] = "console.log(" . json_encode($m) . ");"; |
|
128 | + $line[] = "console.log(".json_encode($m).");"; |
|
129 | 129 | } else { |
130 | - $line[] = "console.log(" . json_encode(var_export($m, true)) . ");"; |
|
130 | + $line[] = "console.log(".json_encode(var_export($m, true)).");"; |
|
131 | 131 | } |
132 | 132 | break; |
133 | 133 | case '错误': |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $line[] = "console.log(\"%c{$msg}\", \"{$style}\");"; |
142 | 142 | break; |
143 | 143 | default: |
144 | - $m = is_string($key) ? $key . ' ' . $m : $key + 1 . ' ' . $m; |
|
144 | + $m = is_string($key) ? $key.' '.$m : $key + 1.' '.$m; |
|
145 | 145 | $msg = json_encode($m); |
146 | 146 | $line[] = "console.log({$msg});"; |
147 | 147 | break; |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $info = []; |
163 | 163 | |
164 | 164 | foreach ($files as $key => $file) { |
165 | - $info[] = $file . ' ( ' . number_format(filesize($file) / 1024, 2) . ' KB )'; |
|
165 | + $info[] = $file.' ( '.number_format(filesize($file) / 1024, 2).' KB )'; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | return $info; |
@@ -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 | namespace think\debug; |
13 | 13 | |
14 | 14 | use think\App; |
@@ -57,20 +57,20 @@ discard block |
||
57 | 57 | |
58 | 58 | // 页面Trace信息 |
59 | 59 | if ($request->host()) { |
60 | - $uri = $request->protocol() . ' ' . $request->method() . ' : ' . $request->url(true); |
|
60 | + $uri = $request->protocol().' '.$request->method().' : '.$request->url(true); |
|
61 | 61 | } else { |
62 | - $uri = 'cmd:' . implode(' ', $_SERVER['argv']); |
|
62 | + $uri = 'cmd:'.implode(' ', $_SERVER['argv']); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | $base = [ |
66 | - '请求信息' => date('Y-m-d H:i:s', $request->time()) . ' ' . $uri, |
|
67 | - '运行时间' => number_format((float) $runtime, 6) . 's [ 吞吐率:' . $reqs . 'req/s ] 内存消耗:' . $mem . 'kb 文件加载:' . count(get_included_files()), |
|
68 | - '查询信息' => $app->db->getQueryTimes() . ' queries', |
|
69 | - '缓存信息' => $app->cache->getReadTimes() . ' reads,' . $app->cache->getWriteTimes() . ' writes', |
|
66 | + '请求信息' => date('Y-m-d H:i:s', $request->time()).' '.$uri, |
|
67 | + '运行时间' => number_format((float) $runtime, 6).'s [ 吞吐率:'.$reqs.'req/s ] 内存消耗:'.$mem.'kb 文件加载:'.count(get_included_files()), |
|
68 | + '查询信息' => $app->db->getQueryTimes().' queries', |
|
69 | + '缓存信息' => $app->cache->getReadTimes().' reads,'.$app->cache->getWriteTimes().' writes', |
|
70 | 70 | ]; |
71 | 71 | |
72 | 72 | if ($app->session->getId(false)) { |
73 | - $base['会话信息'] = 'SESSION_ID=' . $app->session->getId(); |
|
73 | + $base['会话信息'] = 'SESSION_ID='.$app->session->getId(); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | $info = $this->getFileInfo(); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | } |
103 | 103 | // 调用Trace页面模板 |
104 | 104 | ob_start(); |
105 | - include $this->config['file'] ?: __DIR__ . '/../../tpl/page_trace.tpl'; |
|
105 | + include $this->config['file'] ?: __DIR__.'/../../tpl/page_trace.tpl'; |
|
106 | 106 | return ob_get_clean(); |
107 | 107 | } |
108 | 108 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $info = []; |
118 | 118 | |
119 | 119 | foreach ($files as $key => $file) { |
120 | - $info[] = $file . ' ( ' . number_format(filesize($file) / 1024, 2) . ' KB )'; |
|
120 | + $info[] = $file.' ( '.number_format(filesize($file) / 1024, 2).' KB )'; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | return $info; |
@@ -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\middleware; |
14 | 14 | |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | |
88 | 88 | if (isset($key) && 200 == $response->getCode() && $response->isAllowCache()) { |
89 | 89 | $header = $response->getHeader(); |
90 | - $header['Cache-Control'] = 'max-age=' . $expire . ',must-revalidate'; |
|
91 | - $header['Last-Modified'] = gmdate('D, d M Y H:i:s') . ' GMT'; |
|
92 | - $header['Expires'] = gmdate('D, d M Y H:i:s', time() + $expire) . ' GMT'; |
|
90 | + $header['Cache-Control'] = 'max-age='.$expire.',must-revalidate'; |
|
91 | + $header['Last-Modified'] = gmdate('D, d M Y H:i:s').' GMT'; |
|
92 | + $header['Expires'] = gmdate('D, d M Y H:i:s', time() + $expire).' GMT'; |
|
93 | 93 | |
94 | 94 | $this->cache->tag($tag)->set($key, [$response->getContent(), $header], $expire); |
95 | 95 | } |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | if (false !== strpos($key, ':')) { |
139 | 139 | $param = $request->param(); |
140 | 140 | foreach ($param as $item => $val) { |
141 | - if (is_string($val) && false !== strpos($key, ':' . $item)) { |
|
142 | - $key = str_replace(':' . $item, $val, $key); |
|
141 | + if (is_string($val) && false !== strpos($key, ':'.$item)) { |
|
142 | + $key = str_replace(':'.$item, $val, $key); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | } elseif (strpos($key, ']')) { |
146 | - if ('[' . $request->ext() . ']' == $key) { |
|
146 | + if ('['.$request->ext().']' == $key) { |
|
147 | 147 | // 缓存某个后缀的请求 |
148 | 148 | $key = md5($request->url()); |
149 | 149 | } else { |
@@ -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\middleware; |
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\middleware; |
14 | 14 | |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | // trace调试信息注入 |
79 | 79 | $pos = strripos($content, '</body>'); |
80 | 80 | if (false !== $pos) { |
81 | - $content = substr($content, 0, $pos) . $output . substr($content, $pos); |
|
81 | + $content = substr($content, 0, $pos).$output.substr($content, $pos); |
|
82 | 82 | } else { |
83 | - $content = $content . $output; |
|
83 | + $content = $content.$output; |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | } |
@@ -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\middleware; |
14 | 14 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | if ($lang->defaultLangSet() != $langset) { |
41 | 41 | // 加载系统语言包 |
42 | 42 | $lang->load([ |
43 | - $app->getThinkPath() . 'lang' . DIRECTORY_SEPARATOR . $langset . '.php', |
|
43 | + $app->getThinkPath().'lang'.DIRECTORY_SEPARATOR.$langset.'.php', |
|
44 | 44 | ]); |
45 | 45 | |
46 | 46 | $app->LoadLangPack($langset); |
@@ -46,7 +46,7 @@ |
||
46 | 46 | |
47 | 47 | $target = $this->getTargetFile($directory, $name); |
48 | 48 | |
49 | - set_error_handler(function ($type, $msg) use (&$error) { |
|
49 | + set_error_handler(function($type, $msg) use (&$error) { |
|
50 | 50 | $error = $msg; |
51 | 51 | }); |
52 | 52 |