Completed
Pull Request — 6.0 (#1895)
by nhzex
04:53
created
src/think/db/Query.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/think/db/Raw.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/think/db/exception/DataNotFoundException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 // +----------------------------------------------------------------------
9 9
 // | Author: 麦当苗儿 <[email protected]> <http://zjzit.cn>
10 10
 // +----------------------------------------------------------------------
11
-declare (strict_types = 1);
11
+declare(strict_types=1);
12 12
 
13 13
 namespace think\db\exception;
14 14
 
Please login to merge, or discard this patch.
src/think/db/exception/BindParamException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 // +----------------------------------------------------------------------
9 9
 // | Author: 麦当苗儿 <[email protected]> <http://zjzit.cn>
10 10
 // +----------------------------------------------------------------------
11
-declare (strict_types = 1);
11
+declare(strict_types=1);
12 12
 
13 13
 namespace think\db\exception;
14 14
 
Please login to merge, or discard this patch.
src/think/cache/driver/Memcache.php 1 patch
Spacing   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -56,8 +56,7 @@  discard block
 block discarded – undo
56 56
         foreach ($hosts as $i => $host) {
57 57
             $port = $ports[$i] ?? $ports[0];
58 58
             $this->options['timeout'] > 0 ?
59
-            $this->handler->addServer($host, (int) $port, $this->options['persistent'], 1, $this->options['timeout']) :
60
-            $this->handler->addServer($host, (int) $port, $this->options['persistent'], 1);
59
+            $this->handler->addServer($host, (int) $port, $this->options['persistent'], 1, $this->options['timeout']) : $this->handler->addServer($host, (int) $port, $this->options['persistent'], 1);
61 60
         }
62 61
     }
63 62
 
@@ -174,8 +173,7 @@  discard block
 block discarded – undo
174 173
         $key = $this->getCacheKey($name);
175 174
 
176 175
         return false === $ttl ?
177
-        $this->handler->delete($key) :
178
-        $this->handler->delete($key, $ttl);
176
+        $this->handler->delete($key) : $this->handler->delete($key, $ttl);
179 177
     }
180 178
 
181 179
     /**
Please login to merge, or discard this patch.
src/think/db/Connection.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
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
 
@@ -449,9 +449,9 @@  discard block
 block discarded – undo
449 449
         } else {
450 450
             if (true === $key) {
451 451
                 if (!empty($query->getOptions('key'))) {
452
-                    $key = 'think:' . $this->getConfig('database') . '.' . $query->getTable() . '|' . $query->getOptions('key');
452
+                    $key = 'think:'.$this->getConfig('database').'.'.$query->getTable().'|'.$query->getOptions('key');
453 453
                 } else {
454
-                    $key = md5($this->getConfig('database') . serialize($query->getOptions()));
454
+                    $key = md5($this->getConfig('database').serialize($query->getOptions()));
455 455
                 }
456 456
             }
457 457
 
@@ -475,15 +475,15 @@  discard block
 block discarded – undo
475 475
      */
476 476
     public function lazyWrite(string $type, string $guid, float $step, int $lazyTime)
477 477
     {
478
-        if (!$this->cache->has($guid . '_time')) {
478
+        if (!$this->cache->has($guid.'_time')) {
479 479
             // 计时开始
480
-            $this->cache->set($guid . '_time', time(), 0);
480
+            $this->cache->set($guid.'_time', time(), 0);
481 481
             $this->cache->$type($guid, $step);
482
-        } elseif (time() > $this->cache->get($guid . '_time') + $lazyTime) {
482
+        } elseif (time() > $this->cache->get($guid.'_time') + $lazyTime) {
483 483
             // 删除缓存
484 484
             $value = $this->cache->$type($guid, $step);
485 485
             $this->cache->delete($guid);
486
-            $this->cache->delete($guid . '_time');
486
+            $this->cache->delete($guid.'_time');
487 487
             return 0 === $value ? false : $value;
488 488
         } else {
489 489
             // 更新缓存
Please login to merge, or discard this patch.
src/think/db/Fetch.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
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
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     {
62 62
         $this->query->parseOptions();
63 63
 
64
-        $field = $aggregate . '(' . $this->builder->parseKey($this->query, $field) . ') AS tp_' . strtolower($aggregate);
64
+        $field = $aggregate.'('.$this->builder->parseKey($this->query, $field).') AS tp_'.strtolower($aggregate);
65 65
 
66 66
         return $this->value($field, 0, false);
67 67
     }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
         }
112 112
 
113 113
         if ($key && '*' != $field) {
114
-            $field = $key . ',' . $field;
114
+            $field = $key.','.$field;
115 115
         }
116 116
 
117 117
         $field = array_map('trim', explode(',', $field));
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
         if (!empty($options['group'])) {
422 422
             // 支持GROUP
423 423
             $bind   = $this->query->getBind();
424
-            $subSql = $this->query->options($options)->field('count(' . $field . ') AS think_count')->bind($bind)->buildSql();
424
+            $subSql = $this->query->options($options)->field('count('.$field.') AS think_count')->bind($bind)->buildSql();
425 425
 
426 426
             $query = $this->query->newQuery()->table([$subSql => '_group_count_']);
427 427
 
Please login to merge, or discard this patch.
src/think/db/connector/Mysql.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
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\connector;
14 14
 
@@ -81,16 +81,16 @@  discard block
 block discarded – undo
81 81
     protected function parseDsn(array $config): string
82 82
     {
83 83
         if (!empty($config['socket'])) {
84
-            $dsn = 'mysql:unix_socket=' . $config['socket'];
84
+            $dsn = 'mysql:unix_socket='.$config['socket'];
85 85
         } elseif (!empty($config['hostport'])) {
86
-            $dsn = 'mysql:host=' . $config['hostname'] . ';port=' . $config['hostport'];
86
+            $dsn = 'mysql:host='.$config['hostname'].';port='.$config['hostport'];
87 87
         } else {
88
-            $dsn = 'mysql:host=' . $config['hostname'];
88
+            $dsn = 'mysql:host='.$config['hostname'];
89 89
         }
90
-        $dsn .= ';dbname=' . $config['database'];
90
+        $dsn .= ';dbname='.$config['database'];
91 91
 
92 92
         if (!empty($config['charset'])) {
93
-            $dsn .= ';charset=' . $config['charset'];
93
+            $dsn .= ';charset='.$config['charset'];
94 94
         }
95 95
 
96 96
         return $dsn;
@@ -110,10 +110,10 @@  discard block
 block discarded – undo
110 110
             if (strpos($tableName, '.')) {
111 111
                 $tableName = str_replace('.', '`.`', $tableName);
112 112
             }
113
-            $tableName = '`' . $tableName . '`';
113
+            $tableName = '`'.$tableName.'`';
114 114
         }
115 115
 
116
-        $sql    = 'SHOW FULL COLUMNS FROM ' . $tableName;
116
+        $sql    = 'SHOW FULL COLUMNS FROM '.$tableName;
117 117
         $pdo    = $this->getPDOStatement($sql);
118 118
         $result = $pdo->fetchAll(PDO::FETCH_ASSOC);
119 119
         $info   = [];
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
      */
146 146
     public function getTables(string $dbName = ''): array
147 147
     {
148
-        $sql    = !empty($dbName) ? 'SHOW TABLES FROM ' . $dbName : 'SHOW TABLES ';
148
+        $sql    = !empty($dbName) ? 'SHOW TABLES FROM '.$dbName : 'SHOW TABLES ';
149 149
         $pdo    = $this->getPDOStatement($sql);
150 150
         $result = $pdo->fetchAll(PDO::FETCH_ASSOC);
151 151
         $info   = [];
@@ -165,13 +165,13 @@  discard block
 block discarded – undo
165 165
      */
166 166
     protected function getExplain(string $sql): array
167 167
     {
168
-        $pdo    = $this->linkID->query("EXPLAIN " . $sql);
168
+        $pdo    = $this->linkID->query("EXPLAIN ".$sql);
169 169
         $result = $pdo->fetch(PDO::FETCH_ASSOC);
170 170
         $result = array_change_key_case($result);
171 171
 
172 172
         if (isset($result['extra'])) {
173 173
             if (strpos($result['extra'], 'filesort') || strpos($result['extra'], 'temporary')) {
174
-                $this->log('SQL:' . $this->queryStr . '[' . $result['extra'] . ']', 'warn');
174
+                $this->log('SQL:'.$this->queryStr.'['.$result['extra'].']', 'warn');
175 175
             }
176 176
         }
177 177
 
Please login to merge, or discard this patch.
src/think/db/PDOConnection.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1812,9 +1812,11 @@
 block discarded – undo
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'];
Please login to merge, or discard this patch.
Spacing   +24 added lines, -25 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
381 381
             $startTime             = microtime(true);
382 382
             $this->links[$linkNum] = $this->createPdo($config['dsn'], $config['username'], $config['password'], $params);
383 383
             // 记录数据库连接信息
384
-            $this->log('CONNECT:[ UseTime:' . number_format(microtime(true) - $startTime, 6) . 's ] ' . $config['dsn']);
384
+            $this->log('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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     /**
@@ -1403,13 +1402,13 @@  discard block
 block discarded – undo
1403 1402
     {
1404 1403
         if ($this->PDOStatement) {
1405 1404
             $error = $this->PDOStatement->errorInfo();
1406
-            $error = $error[1] . ':' . $error[2];
1405
+            $error = $error[1].':'.$error[2];
1407 1406
         } else {
1408 1407
             $error = '';
1409 1408
         }
1410 1409
 
1411 1410
         if ('' != $this->queryStr) {
1412
-            $error .= "\n [ SQL语句 ] : " . $this->getLastsql();
1411
+            $error .= "\n [ SQL语句 ] : ".$this->getLastsql();
1413 1412
         }
1414 1413
 
1415 1414
         return $error;
@@ -1473,10 +1472,10 @@  discard block
 block discarded – undo
1473 1472
             }
1474 1473
 
1475 1474
             // 未注册监听则记录到日志中
1476
-            $this->log($sql . ' [ ' . $master . 'RunTime:' . $runtime . 's ]');
1475
+            $this->log($sql.' [ '.$master.'RunTime:'.$runtime.'s ]');
1477 1476
 
1478 1477
             if (!empty($explain)) {
1479
-                $this->log('[ EXPLAIN : ' . var_export($explain, true) . ' ]');
1478
+                $this->log('[ EXPLAIN : '.var_export($explain, true).' ]');
1480 1479
             }
1481 1480
         }
1482 1481
     }
@@ -1578,9 +1577,9 @@  discard block
 block discarded – undo
1578 1577
         } else {
1579 1578
             if (true === $key) {
1580 1579
                 if (!empty($query->getOptions('key'))) {
1581
-                    $key = 'think:' . $this->getConfig('database') . '.' . $query->getTable() . '|' . $query->getOptions('key');
1580
+                    $key = 'think:'.$this->getConfig('database').'.'.$query->getTable().'|'.$query->getOptions('key');
1582 1581
                 } else {
1583
-                    $key = md5($this->getConfig('database') . serialize($query->getOptions()) . serialize($query->getBind(false)));
1582
+                    $key = md5($this->getConfig('database').serialize($query->getOptions()).serialize($query->getBind(false)));
1584 1583
                 }
1585 1584
             }
1586 1585
 
Please login to merge, or discard this patch.