@@ -65,9 +65,9 @@ |
||
65 | 65 | $desc = $info['description']; |
66 | 66 | $ms = number_format($time * 1000, 3, '.', ''); |
67 | 67 | if (strlen($desc)) { |
68 | - $timing[] = $name . ';desc="' . $desc . '";dur=' . $ms; |
|
68 | + $timing[] = $name.';desc="'.$desc.'";dur='.$ms; |
|
69 | 69 | } else { |
70 | - $timing[] = $name . ';dur=' . $ms; |
|
70 | + $timing[] = $name.';dur='.$ms; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | $response->setHeader('server-timing', implode(',', $timing)); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | $this->config = $config; |
79 | 79 | $this->name = $name ?? 'anonymous'; |
80 | 80 | $this->observer = new NullObserver; |
81 | - register_shutdown_function(function () { |
|
81 | + register_shutdown_function(function() { |
|
82 | 82 | $this->onBeforeSystemShutdown(); |
83 | 83 | }); |
84 | 84 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $this->pdo = $this->createPDO(); |
109 | 109 | $this->observer->connectDatabase(microtime(true) - $time); |
110 | 110 | $this->id = static::$connectionCount; |
111 | - static::$connectionCount ++; |
|
111 | + static::$connectionCount++; |
|
112 | 112 | } catch (PDOException $e) { |
113 | 113 | throw new SQLException(sprintf( |
114 | 114 | "%s connect database error:%s", |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | public function beginTransaction() |
201 | 201 | { |
202 | 202 | $this->prepareConnection(); |
203 | - $this->transaction ++; |
|
203 | + $this->transaction++; |
|
204 | 204 | if ($this->transaction == 1) { |
205 | 205 | $this->pdo->beginTransaction(); |
206 | 206 | } |
@@ -8,25 +8,25 @@ discard block |
||
8 | 8 | use suda\application\builder\ApplicationBuilder; |
9 | 9 | use suda\framework\http\HTTPResponse as Response; |
10 | 10 | |
11 | -require_once __DIR__ . '/loader.php'; |
|
11 | +require_once __DIR__.'/loader.php'; |
|
12 | 12 | |
13 | 13 | // 初始化系统加载器 |
14 | 14 | $loader = new Loader; |
15 | 15 | $loader->register(); |
16 | -$loader->addIncludePath(SUDA_SYSTEM . '/src', 'suda'); |
|
16 | +$loader->addIncludePath(SUDA_SYSTEM.'/src', 'suda'); |
|
17 | 17 | // 初始化数据目录 |
18 | 18 | defined('SUDA_DATA') or define('SUDA_DATA', Path::toAbsolutePath('~/data')); |
19 | -defined('SUDA_APP_MANIFEST') or define('SUDA_APP_MANIFEST', SUDA_APP . '/manifest'); |
|
19 | +defined('SUDA_APP_MANIFEST') or define('SUDA_APP_MANIFEST', SUDA_APP.'/manifest'); |
|
20 | 20 | $application = ApplicationBuilder::build($loader, SUDA_APP, SUDA_APP_MANIFEST, SUDA_DATA); |
21 | 21 | // 日志路径 |
22 | -defined('SUDA_DEBUG_LOG_PATH') or define('SUDA_DEBUG_LOG_PATH', $application->getDataPath() . '/logs'); |
|
22 | +defined('SUDA_DEBUG_LOG_PATH') or define('SUDA_DEBUG_LOG_PATH', $application->getDataPath().'/logs'); |
|
23 | 23 | // 文件日志 |
24 | 24 | $logger = new FileLogger( |
25 | 25 | [ |
26 | 26 | 'log-level' => SUDA_DEBUG_LEVEL, |
27 | 27 | 'save-path' => SUDA_DEBUG_LOG_PATH, |
28 | - 'save-dump-path' => SUDA_DEBUG_LOG_PATH . '/dump', |
|
29 | - 'save-zip-path' => SUDA_DEBUG_LOG_PATH . '/zip', |
|
28 | + 'save-dump-path' => SUDA_DEBUG_LOG_PATH.'/dump', |
|
29 | + 'save-zip-path' => SUDA_DEBUG_LOG_PATH.'/zip', |
|
30 | 30 | 'log-format' => '%message%', |
31 | 31 | ] |
32 | 32 | ); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | 'start-time' => defined('SUDA_START_TIME') ? constant('SUDA_START_TIME') : microtime(true), |
38 | 38 | 'start-memory' => defined('SUDA_START_MEMORY') ? constant('SUDA_START_MEMORY') : memory_get_usage(), |
39 | 39 | ]); |
40 | -$application->getConfig()->set('save-dump-path', SUDA_DEBUG_LOG_PATH .'/dump'); |
|
40 | +$application->getConfig()->set('save-dump-path', SUDA_DEBUG_LOG_PATH.'/dump'); |
|
41 | 41 | $application->getConfig()->set('response-timing', SUDA_DEBUG); |
42 | 42 | $application->run(Request::create(), new Response); |
43 | 43 | exit; |
@@ -178,7 +178,7 @@ |
||
178 | 178 | */ |
179 | 179 | private function registerModule() |
180 | 180 | { |
181 | - $extractPath = $this->application->getDataPath() . '/extract-module'; |
|
181 | + $extractPath = $this->application->getDataPath().'/extract-module'; |
|
182 | 182 | FileSystem::make($extractPath); |
183 | 183 | foreach ($this->application->getModulePaths() as $path) { |
184 | 184 | $this->registerModuleFrom($path, $extractPath); |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | $fields = $reads; |
28 | 28 | } else { |
29 | 29 | $field = []; |
30 | - $prefix = strlen($table) ?"`{$table}`." :''; |
|
30 | + $prefix = strlen($table) ? "`{$table}`." : ''; |
|
31 | 31 | foreach ($reads as $want) { |
32 | 32 | $field[] = $prefix."`$want`"; |
33 | 33 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | protected function mergeBinder(array $binderArray, array $parameter) |
66 | 66 | { |
67 | 67 | foreach ($parameter as $key => $value) { |
68 | - if (! ($value instanceof Binder)) { |
|
68 | + if (!($value instanceof Binder)) { |
|
69 | 69 | $value = new Binder($key, $value); |
70 | 70 | } |
71 | 71 | if (!in_array($value, $binderArray)) { |
@@ -210,10 +210,10 @@ |
||
210 | 210 | list($updateSet, $upBinder) = $this->prepareUpdateSet($this->data); |
211 | 211 | $this->binder = array_merge($this->binder, $upBinder); |
212 | 212 | } |
213 | - $string = "UPDATE " . $this->table . " SET " . $updateSet . " WHERE " . $this->whereCondition; |
|
213 | + $string = "UPDATE ".$this->table." SET ".$updateSet." WHERE ".$this->whereCondition; |
|
214 | 214 | return new Query($string, $this->binder); |
215 | 215 | } else { |
216 | - $string = "DELETE FROM " . $this->table . " WHERE " . $this->whereCondition; |
|
216 | + $string = "DELETE FROM ".$this->table." WHERE ".$this->whereCondition; |
|
217 | 217 | return new Query($string, $this->binder); |
218 | 218 | } |
219 | 219 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | public function prepareQueryMark(string $sql, array $parameter) |
22 | 22 | { |
23 | 23 | $binders = []; |
24 | - $query = preg_replace_callback('/\?/', function ($match) use (&$binders, $parameter) { |
|
24 | + $query = preg_replace_callback('/\?/', function($match) use (&$binders, $parameter) { |
|
25 | 25 | $index = count($binders); |
26 | 26 | if (array_key_exists($index, $parameter)) { |
27 | 27 | $name = Binder::index($index); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | } else { |
33 | 33 | $binder = new Binder($name, $parameter[$index]); |
34 | 34 | $binders[] = $binder; |
35 | - return ':' . $binder->getName(); |
|
35 | + return ':'.$binder->getName(); |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | return $match[0]; |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | public function prepareInParameter($values, string $name) |
51 | 51 | { |
52 | 52 | if ($this->count($values) <= 0) { |
53 | - throw new SQLException('on field ' . $name . ' value can\'t be empty array'); |
|
53 | + throw new SQLException('on field '.$name.' value can\'t be empty array'); |
|
54 | 54 | } |
55 | 55 | $names = []; |
56 | 56 | $binders = []; |
57 | 57 | foreach ($values as $value) { |
58 | 58 | $_name = Binder::index($name); |
59 | 59 | $binders[] = new Binder($_name, $value); |
60 | - $names[] = ':' . $_name; |
|
60 | + $names[] = ':'.$_name; |
|
61 | 61 | } |
62 | 62 | return [implode(',', $names), $binders]; |
63 | 63 | } |
@@ -85,10 +85,10 @@ discard block |
||
85 | 85 | public function createQueryOperation(string $name, string $operator, $value, string $indexName = '') |
86 | 86 | { |
87 | 87 | if ($value instanceof Query) { |
88 | - return new Query("`{$name}` {$operator} " . $value, $value->getBinder()); |
|
88 | + return new Query("`{$name}` {$operator} ".$value, $value->getBinder()); |
|
89 | 89 | } |
90 | 90 | if ($value instanceof Statement) { |
91 | - return new Query("`{$name}` {$operator} (" . $value->getQuery() . ')', $value->getBinder()); |
|
91 | + return new Query("`{$name}` {$operator} (".$value->getQuery().')', $value->getBinder()); |
|
92 | 92 | } |
93 | 93 | if ($value instanceof IteratorAggregate || is_array($value)) { |
94 | 94 | return $this->prepareIn($name, $operator, $value); |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | return $this->createQueryOperation($name, 'in', $values); |
230 | 230 | } |
231 | 231 | list($inSQL, $binders) = $this->prepareInParameter($values, $name); |
232 | - $sql = '`' . $name . '` ' . strtoupper($operation) . ' (' . $inSQL . ')'; |
|
232 | + $sql = '`'.$name.'` '.strtoupper($operation).' ('.$inSQL.')'; |
|
233 | 233 | return new Query($sql, $binders); |
234 | 234 | } |
235 | 235 | |
@@ -244,6 +244,6 @@ discard block |
||
244 | 244 | public function replaceQuote(string $name, string $replace, string $target) |
245 | 245 | { |
246 | 246 | $name = ltrim($name, ':'); |
247 | - return preg_replace('/(?<!_):' . preg_quote($name) . '/', $replace, $target); |
|
247 | + return preg_replace('/(?<!_):'.preg_quote($name).'/', $replace, $target); |
|
248 | 248 | } |
249 | 249 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | protected function whereStringArray(string $where, array $whereBinder) |
198 | 198 | { |
199 | 199 | list($where, $whereBinder) = $this->prepareWhereString($where, $whereBinder); |
200 | - $this->where = 'WHERE ' . $where; |
|
200 | + $this->where = 'WHERE '.$where; |
|
201 | 201 | $this->binder = $this->mergeBinder($this->binder, $whereBinder); |
202 | 202 | } |
203 | 203 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | public function groupBy(string $what) |
211 | 211 | { |
212 | 212 | $what = $this->middleware->inputName($what); |
213 | - $this->groupBy = 'GROUP BY `' . $what . '`'; |
|
213 | + $this->groupBy = 'GROUP BY `'.$what.'`'; |
|
214 | 214 | return $this; |
215 | 215 | } |
216 | 216 | |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | protected function havingStringArray(string $having, array $havingBinder) |
254 | 254 | { |
255 | 255 | list($having, $havingBinder) = $this->prepareWhereString($having, $havingBinder); |
256 | - $this->having = 'HAVING ' . $having; |
|
256 | + $this->having = 'HAVING '.$having; |
|
257 | 257 | $this->binder = $this->mergeBinder($this->binder, $havingBinder); |
258 | 258 | } |
259 | 259 | |
@@ -269,9 +269,9 @@ discard block |
||
269 | 269 | $what = $this->middleware->inputName($what); |
270 | 270 | $order = strtoupper($order); |
271 | 271 | if (strlen($this->orderBy) > 0) { |
272 | - $this->orderBy .= ',`' . $what . '` ' . $order; |
|
272 | + $this->orderBy .= ',`'.$what.'` '.$order; |
|
273 | 273 | } else { |
274 | - $this->orderBy = 'ORDER BY `' . $what . '` ' . $order; |
|
274 | + $this->orderBy = 'ORDER BY `'.$what.'` '.$order; |
|
275 | 275 | } |
276 | 276 | return $this; |
277 | 277 | } |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | */ |
294 | 294 | public function limit(int $start, int $length = null) |
295 | 295 | { |
296 | - $this->limit = 'LIMIT ' . $start . ($length !== null ? ',' . $length : ''); |
|
296 | + $this->limit = 'LIMIT '.$start.($length !== null ? ','.$length : ''); |
|
297 | 297 | return $this; |
298 | 298 | } |
299 | 299 |
@@ -88,10 +88,10 @@ discard block |
||
88 | 88 | */ |
89 | 89 | protected function sendMultipleFileByRange(Response $response, array $ranges) |
90 | 90 | { |
91 | - $separates = 'multiple_range_' . base64_encode(md5(uniqid(), true)); |
|
92 | - $response->setHeader('content-type', 'multipart/byteranges; boundary=' . $separates); |
|
91 | + $separates = 'multiple_range_'.base64_encode(md5(uniqid(), true)); |
|
92 | + $response->setHeader('content-type', 'multipart/byteranges; boundary='.$separates); |
|
93 | 93 | foreach ($ranges as $range) { |
94 | - $response->write('--' . $separates . "\r\n"); |
|
94 | + $response->write('--'.$separates."\r\n"); |
|
95 | 95 | $this->sendMultipleRangePart($response, $range); |
96 | 96 | $this->sendFileByRange($response, $range); |
97 | 97 | $response->write("\r\n"); |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | */ |
139 | 139 | protected function sendMultipleRangePart(Response $response, array $range) |
140 | 140 | { |
141 | - $response->write('Content-Type: ' . $this->mime . "\r\n"); |
|
142 | - $response->write('Content-Range: ' . $this->getRangeHeader($range) . "\r\n\r\n"); |
|
141 | + $response->write('Content-Type: '.$this->mime."\r\n"); |
|
142 | + $response->write('Content-Range: '.$this->getRangeHeader($range)."\r\n\r\n"); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |