@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | // +---------------------------------------------------------------------- |
137 | 137 | |
138 | 138 | // 默认跳转页面对应的模板文件 |
139 | - 'dispatch_success_tmpl' => __DIR__ . '/tpl/dispatch_jump.tpl', |
|
140 | - 'dispatch_error_tmpl' => __DIR__ . '/tpl/dispatch_jump.tpl', |
|
139 | + 'dispatch_success_tmpl' => __DIR__.'/tpl/dispatch_jump.tpl', |
|
140 | + 'dispatch_error_tmpl' => __DIR__.'/tpl/dispatch_jump.tpl', |
|
141 | 141 | // 异常页面的模板文件 |
142 | - 'exception_tmpl' => __DIR__ . '/tpl/think_exception.tpl', |
|
142 | + 'exception_tmpl' => __DIR__.'/tpl/think_exception.tpl', |
|
143 | 143 | // 错误显示信息,非调试模式有效 |
144 | 144 | 'error_message' => '页面错误!请稍后再试~', |
145 | 145 | // 显示错误信息 |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | 'trace' => [ |
200 | 200 | // 内置Html Console 支持扩展 |
201 | 201 | 'type' => 'Html', |
202 | - 'file' => __DIR__ . '/tpl/page_trace.tpl', |
|
202 | + 'file' => __DIR__.'/tpl/page_trace.tpl', |
|
203 | 203 | ], |
204 | 204 | |
205 | 205 | // +---------------------------------------------------------------------- |
@@ -11,7 +11,7 @@ |
||
11 | 11 | namespace think; |
12 | 12 | |
13 | 13 | // 载入Loader类 |
14 | -require __DIR__ . '/library/think/Loader.php'; |
|
14 | +require __DIR__.'/library/think/Loader.php'; |
|
15 | 15 | |
16 | 16 | // 注册自动加载 |
17 | 17 | Loader::register(); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | protected function getEnv($name, $default = null, $php_prefix = true) |
62 | 62 | { |
63 | 63 | if ($php_prefix) { |
64 | - $name = 'PHP_' . $name; |
|
64 | + $name = 'PHP_'.$name; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | $result = getenv($name); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | foreach ($env as $key => $val) { |
99 | 99 | if (is_array($val)) { |
100 | 100 | foreach ($val as $k => $v) { |
101 | - $this->data[$key . '_' . strtoupper($k)] = $v; |
|
101 | + $this->data[$key.'_'.strtoupper($k)] = $v; |
|
102 | 102 | } |
103 | 103 | } else { |
104 | 104 | $this->data[$key] = $val; |
@@ -55,21 +55,21 @@ discard block |
||
55 | 55 | $mem = number_format((memory_get_usage() - Container::get('app')->getBeginMem()) / 1024, 2); |
56 | 56 | |
57 | 57 | if ($request->host()) { |
58 | - $uri = $request->protocol() . ' ' . $request->method() . ' : ' . $request->url(true); |
|
58 | + $uri = $request->protocol().' '.$request->method().' : '.$request->url(true); |
|
59 | 59 | } else { |
60 | - $uri = 'cmd:' . implode(' ', $_SERVER['argv']); |
|
60 | + $uri = 'cmd:'.implode(' ', $_SERVER['argv']); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | // 页面Trace信息 |
64 | 64 | $base = [ |
65 | - '请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $uri, |
|
66 | - '运行时间' => number_format($runtime, 6) . 's [ 吞吐率:' . $reqs . 'req/s ] 内存消耗:' . $mem . 'kb 文件加载:' . count(get_included_files()), |
|
67 | - '查询信息' => Db::$queryTimes . ' queries ' . Db::$executeTimes . ' writes ', |
|
68 | - '缓存信息' => Container::get('cache')->getReadTimes() . ' reads,' . Container::get('cache')->getWriteTimes() . ' writes', |
|
65 | + '请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']).' '.$uri, |
|
66 | + '运行时间' => number_format($runtime, 6).'s [ 吞吐率:'.$reqs.'req/s ] 内存消耗:'.$mem.'kb 文件加载:'.count(get_included_files()), |
|
67 | + '查询信息' => Db::$queryTimes.' queries '.Db::$executeTimes.' writes ', |
|
68 | + '缓存信息' => Container::get('cache')->getReadTimes().' reads,'.Container::get('cache')->getWriteTimes().' writes', |
|
69 | 69 | ]; |
70 | 70 | |
71 | 71 | if (session_id()) { |
72 | - $base['会话信息'] = 'SESSION_ID=' . session_id(); |
|
72 | + $base['会话信息'] = 'SESSION_ID='.session_id(); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | $info = Container::get('debug')->getFile(true); |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | case '调试': |
128 | 128 | $var_type = gettype($m); |
129 | 129 | if (in_array($var_type, ['array', 'string'])) { |
130 | - $line[] = "console.log(" . json_encode($m) . ");"; |
|
130 | + $line[] = "console.log(".json_encode($m).");"; |
|
131 | 131 | } else { |
132 | - $line[] = "console.log(" . json_encode(var_export($m, 1)) . ");"; |
|
132 | + $line[] = "console.log(".json_encode(var_export($m, 1)).");"; |
|
133 | 133 | } |
134 | 134 | break; |
135 | 135 | case '错误': |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $line[] = "console.log(\"%c{$msg}\", \"{$style}\");"; |
144 | 144 | break; |
145 | 145 | default: |
146 | - $m = is_string($key) ? $key . ' ' . $m : $key + 1 . ' ' . $m; |
|
146 | + $m = is_string($key) ? $key.' '.$m : $key + 1.' '.$m; |
|
147 | 147 | $msg = json_encode($m); |
148 | 148 | $line[] = "console.log({$msg});"; |
149 | 149 | break; |
@@ -55,19 +55,19 @@ |
||
55 | 55 | |
56 | 56 | // 页面Trace信息 |
57 | 57 | if ($request->host()) { |
58 | - $uri = $request->protocol() . ' ' . $request->method() . ' : ' . $request->url(true); |
|
58 | + $uri = $request->protocol().' '.$request->method().' : '.$request->url(true); |
|
59 | 59 | } else { |
60 | - $uri = 'cmd:' . implode(' ', $_SERVER['argv']); |
|
60 | + $uri = 'cmd:'.implode(' ', $_SERVER['argv']); |
|
61 | 61 | } |
62 | 62 | $base = [ |
63 | - '请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $uri, |
|
64 | - '运行时间' => number_format($runtime, 6) . 's [ 吞吐率:' . $reqs . 'req/s ] 内存消耗:' . $mem . 'kb 文件加载:' . count(get_included_files()), |
|
65 | - '查询信息' => Db::$queryTimes . ' queries ' . Db::$executeTimes . ' writes ', |
|
66 | - '缓存信息' => Container::get('cache')->getReadTimes() . ' reads,' . Container::get('cache')->getWriteTimes() . ' writes', |
|
63 | + '请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']).' '.$uri, |
|
64 | + '运行时间' => number_format($runtime, 6).'s [ 吞吐率:'.$reqs.'req/s ] 内存消耗:'.$mem.'kb 文件加载:'.count(get_included_files()), |
|
65 | + '查询信息' => Db::$queryTimes.' queries '.Db::$executeTimes.' writes ', |
|
66 | + '缓存信息' => Container::get('cache')->getReadTimes().' reads,'.Container::get('cache')->getWriteTimes().' writes', |
|
67 | 67 | ]; |
68 | 68 | |
69 | 69 | if (session_id()) { |
70 | - $base['会话信息'] = 'SESSION_ID=' . session_id(); |
|
70 | + $base['会话信息'] = 'SESSION_ID='.session_id(); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | $info = Container::get('debug')->getFile(true); |
@@ -76,21 +76,21 @@ discard block |
||
76 | 76 | if ($this->app->isDebug()) { |
77 | 77 | $runtime = round(microtime(true) - $this->app->getBeginTime(), 10); |
78 | 78 | $reqs = $runtime > 0 ? number_format(1 / $runtime, 2) : '∞'; |
79 | - $time_str = ' [运行时间:' . number_format($runtime, 6) . 's][吞吐率:' . $reqs . 'req/s]'; |
|
79 | + $time_str = ' [运行时间:'.number_format($runtime, 6).'s][吞吐率:'.$reqs.'req/s]'; |
|
80 | 80 | $memory_use = number_format((memory_get_usage() - $this->app->getBeginMem()) / 1024, 2); |
81 | - $memory_str = ' [内存消耗:' . $memory_use . 'kb]'; |
|
82 | - $file_load = ' [文件加载:' . count(get_included_files()) . ']'; |
|
81 | + $memory_str = ' [内存消耗:'.$memory_use.'kb]'; |
|
82 | + $file_load = ' [文件加载:'.count(get_included_files()).']'; |
|
83 | 83 | |
84 | 84 | if (isset($_SERVER['HTTP_HOST'])) { |
85 | - $current_uri = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
85 | + $current_uri = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; |
|
86 | 86 | } else { |
87 | - $current_uri = 'cmd:' . implode(' ', $_SERVER['argv']); |
|
87 | + $current_uri = 'cmd:'.implode(' ', $_SERVER['argv']); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | // 基本信息 |
91 | 91 | $trace[] = [ |
92 | 92 | 'type' => 'group', |
93 | - 'msg' => $current_uri . $time_str . $memory_str . $file_load, |
|
93 | + 'msg' => $current_uri.$time_str.$memory_str.$file_load, |
|
94 | 94 | 'css' => $this->css['page'], |
95 | 95 | ]; |
96 | 96 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | foreach ($log as $type => $val) { |
99 | 99 | $trace[] = [ |
100 | 100 | 'type' => in_array($type, $this->config['expand_level']) ? 'group' : 'groupCollapsed', |
101 | - 'msg' => '[ ' . $type . ' ]', |
|
101 | + 'msg' => '[ '.$type.' ]', |
|
102 | 102 | 'css' => isset($this->css[$type]) ? $this->css[$type] : '', |
103 | 103 | ]; |
104 | 104 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | ]; |
185 | 185 | |
186 | 186 | $msg = @json_encode($logs); |
187 | - $address = '/' . $client_id; //将client_id作为地址, server端通过地址判断将日志发布给谁 |
|
187 | + $address = '/'.$client_id; //将client_id作为地址, server端通过地址判断将日志发布给谁 |
|
188 | 188 | |
189 | 189 | $this->send($this->config['host'], $msg, $address); |
190 | 190 | } |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | */ |
258 | 258 | protected function send($host, $message = '', $address = '/') |
259 | 259 | { |
260 | - $url = 'http://' . $host . ':' . $this->port . $address; |
|
260 | + $url = 'http://'.$host.':'.$this->port.$address; |
|
261 | 261 | $ch = curl_init(); |
262 | 262 | |
263 | 263 | curl_setopt($ch, CURLOPT_URL, $url); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | } |
93 | 93 | |
94 | 94 | if ($this->parent && $this->parent->getFullName()) { |
95 | - $this->fullName = $this->parent->getFullName() . ($this->name ? '/' . $this->name : ''); |
|
95 | + $this->fullName = $this->parent->getFullName().($this->name ? '/'.$this->name : ''); |
|
96 | 96 | } else { |
97 | 97 | $this->fullName = $this->name; |
98 | 98 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 183 | if ($this->auto) { |
184 | 184 | // 自动解析URL地址 |
185 | - $result = new UrlDispatch($request, $this, $this->auto . '/' . $url, ['auto_search' => false]); |
|
185 | + $result = new UrlDispatch($request, $this, $this->auto.'/'.$url, ['auto_search' => false]); |
|
186 | 186 | } elseif ($this->miss && in_array($this->miss->getMethod(), ['*', $method])) { |
187 | 187 | // 未匹配所有路由的路由规则处理 |
188 | 188 | $result = $this->miss->parseRule($request, '', $this->miss->getRoute(), $url, $this->miss->mergeGroupOptions()); |
@@ -279,11 +279,11 @@ discard block |
||
279 | 279 | protected function checkMergeRuleRegex($request, &$rules, $url, $completeMatch) |
280 | 280 | { |
281 | 281 | $depr = $this->router->config('pathinfo_depr'); |
282 | - $url = $depr . str_replace('|', $depr, $url); |
|
282 | + $url = $depr.str_replace('|', $depr, $url); |
|
283 | 283 | |
284 | 284 | foreach ($rules as $key => $item) { |
285 | 285 | if ($item instanceof RuleItem) { |
286 | - $rule = $depr . str_replace('/', $depr, $item->getRule()); |
|
286 | + $rule = $depr.str_replace('/', $depr, $item->getRule()); |
|
287 | 287 | if ($depr == $rule && $depr != $url) { |
288 | 288 | unset($rules[$key]); |
289 | 289 | continue; |
@@ -300,21 +300,21 @@ discard block |
||
300 | 300 | continue; |
301 | 301 | } |
302 | 302 | |
303 | - $slash = preg_quote('/-' . $depr, '/'); |
|
303 | + $slash = preg_quote('/-'.$depr, '/'); |
|
304 | 304 | |
305 | - if ($matchRule = preg_split('/[' . $slash . ']<\w+\??>/', $rule, 2)) { |
|
305 | + if ($matchRule = preg_split('/['.$slash.']<\w+\??>/', $rule, 2)) { |
|
306 | 306 | if ($matchRule[0] && 0 !== strncasecmp($rule, $url, strlen($matchRule[0]))) { |
307 | 307 | unset($rules[$key]); |
308 | 308 | continue; |
309 | 309 | } |
310 | 310 | } |
311 | 311 | |
312 | - if (preg_match_all('/[' . $slash . ']?<?\w+\??>?/', $rule, $matches)) { |
|
312 | + if (preg_match_all('/['.$slash.']?<?\w+\??>?/', $rule, $matches)) { |
|
313 | 313 | unset($rules[$key]); |
314 | 314 | $pattern = array_merge($this->getPattern(), $item->getPattern()); |
315 | 315 | $option = array_merge($this->getOption(), $item->getOption()); |
316 | 316 | |
317 | - $regex[$key] = $this->buildRuleRegex($rule, $matches[0], $pattern, $option, $complete, '_THINK_' . $key); |
|
317 | + $regex[$key] = $this->buildRuleRegex($rule, $matches[0], $pattern, $option, $complete, '_THINK_'.$key); |
|
318 | 318 | $items[$key] = $item; |
319 | 319 | } |
320 | 320 | } |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | } |
326 | 326 | |
327 | 327 | try { |
328 | - $result = preg_match('/^(?:' . implode('|', $regex) . ')/u', $url, $match); |
|
328 | + $result = preg_match('/^(?:'.implode('|', $regex).')/u', $url, $match); |
|
329 | 329 | } catch (\Exception $e) { |
330 | 330 | throw new Exception('route pattern error'); |
331 | 331 | } |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | |
343 | 343 | if (!isset($pos)) { |
344 | 344 | foreach ($regex as $key => $item) { |
345 | - if (0 === strpos(str_replace(['\/', '\-', '\\' . $depr], ['/', '-', $depr], $item), $match[0])) { |
|
345 | + if (0 === strpos(str_replace(['\/', '\-', '\\'.$depr], ['/', '-', $depr], $item), $match[0])) { |
|
346 | 346 | $pos = $key; |
347 | 347 | break; |
348 | 348 | } |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | public function prefix($prefix) |
506 | 506 | { |
507 | 507 | if ($this->parent && $this->parent->getOption('prefix')) { |
508 | - $prefix = $this->parent->getOption('prefix') . $prefix; |
|
508 | + $prefix = $this->parent->getOption('prefix').$prefix; |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | return $this->option('prefix', $prefix); |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | $item = []; |
80 | 80 | |
81 | 81 | foreach ($array as $val) { |
82 | - $item[] = $val . '/<' . (isset($option['var'][$val]) ? $option['var'][$val] : $val . '_id') . '>'; |
|
82 | + $item[] = $val.'/<'.(isset($option['var'][$val]) ? $option['var'][$val] : $val.'_id').'>'; |
|
83 | 83 | } |
84 | 84 | |
85 | - $rule = implode('/', $item) . '/' . $last; |
|
85 | + $rule = implode('/', $item).'/'.$last; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | $prefix = substr($rule, strlen($this->name) + 1); |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | } |
96 | 96 | |
97 | 97 | if (isset($last) && strpos($val[1], '<id>') && isset($option['var'][$last])) { |
98 | - $val[1] = str_replace('<id>', '<' . $option['var'][$last] . '>', $val[1]); |
|
98 | + $val[1] = str_replace('<id>', '<'.$option['var'][$last].'>', $val[1]); |
|
99 | 99 | } elseif (strpos($val[1], '<id>') && isset($option['var'][$rule])) { |
100 | - $val[1] = str_replace('<id>', '<' . $option['var'][$rule] . '>', $val[1]); |
|
100 | + $val[1] = str_replace('<id>', '<'.$option['var'][$rule].'>', $val[1]); |
|
101 | 101 | } |
102 | 102 | |
103 | - $this->addRule(trim($prefix . $val[1], '/'), $this->route . '/' . $val[2], $val[0]); |
|
103 | + $this->addRule(trim($prefix.$val[1], '/'), $this->route.'/'.$val[2], $val[0]); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | $this->router->setGroup($origin); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $rule = '/' != $rule ? ltrim($rule, '/') : ''; |
67 | 67 | |
68 | 68 | if ($this->parent && $prefix = $this->parent->getFullName()) { |
69 | - $rule = $prefix . ($rule ? '/' . ltrim($rule, '/') : ''); |
|
69 | + $rule = $prefix.($rule ? '/'.ltrim($rule, '/') : ''); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | if (false !== strpos($rule, ':')) { |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | |
217 | 217 | if (isset($option['ext'])) { |
218 | 218 | // 路由ext参数 优先于系统配置的URL伪静态后缀参数 |
219 | - $url = preg_replace('/\.(' . $request->ext() . ')$/i', '', $url); |
|
219 | + $url = preg_replace('/\.('.$request->ext().')$/i', '', $url); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | return $url; |
@@ -240,38 +240,38 @@ discard block |
||
240 | 240 | $depr = $this->router->config('pathinfo_depr'); |
241 | 241 | |
242 | 242 | // 检查完整规则定义 |
243 | - if (isset($pattern['__url__']) && !preg_match(0 === strpos($pattern['__url__'], '/') ? $pattern['__url__'] : '/^' . $pattern['__url__'] . '/', str_replace('|', $depr, $url))) { |
|
243 | + if (isset($pattern['__url__']) && !preg_match(0 === strpos($pattern['__url__'], '/') ? $pattern['__url__'] : '/^'.$pattern['__url__'].'/', str_replace('|', $depr, $url))) { |
|
244 | 244 | return false; |
245 | 245 | } |
246 | 246 | |
247 | 247 | $var = []; |
248 | - $url = $depr . str_replace('|', $depr, $url); |
|
249 | - $rule = $depr . str_replace('/', $depr, $this->rule); |
|
248 | + $url = $depr.str_replace('|', $depr, $url); |
|
249 | + $rule = $depr.str_replace('/', $depr, $this->rule); |
|
250 | 250 | |
251 | 251 | if ($depr == $rule && $depr != $url) { |
252 | 252 | return false; |
253 | 253 | } |
254 | 254 | |
255 | 255 | if (false === strpos($rule, '<')) { |
256 | - if (0 === strcasecmp($rule, $url) || (!$completeMatch && 0 === strncasecmp($rule . $depr, $url . $depr, strlen($rule . $depr)))) { |
|
256 | + if (0 === strcasecmp($rule, $url) || (!$completeMatch && 0 === strncasecmp($rule.$depr, $url.$depr, strlen($rule.$depr)))) { |
|
257 | 257 | return $var; |
258 | 258 | } |
259 | 259 | return false; |
260 | 260 | } |
261 | 261 | |
262 | - $slash = preg_quote('/-' . $depr, '/'); |
|
262 | + $slash = preg_quote('/-'.$depr, '/'); |
|
263 | 263 | |
264 | - if ($matchRule = preg_split('/[' . $slash . ']?<\w+\??>/', $rule, 2)) { |
|
264 | + if ($matchRule = preg_split('/['.$slash.']?<\w+\??>/', $rule, 2)) { |
|
265 | 265 | if ($matchRule[0] && 0 !== strncasecmp($rule, $url, strlen($matchRule[0]))) { |
266 | 266 | return false; |
267 | 267 | } |
268 | 268 | } |
269 | 269 | |
270 | - if (preg_match_all('/[' . $slash . ']?<?\w+\??>?/', $rule, $matches)) { |
|
270 | + if (preg_match_all('/['.$slash.']?<?\w+\??>?/', $rule, $matches)) { |
|
271 | 271 | $regex = $this->buildRuleRegex($rule, $matches[0], $pattern, $option, $completeMatch); |
272 | 272 | |
273 | 273 | try { |
274 | - if (!preg_match('/^' . $regex . ($completeMatch ? '$' : '') . '/u', $url, $match)) { |
|
274 | + if (!preg_match('/^'.$regex.($completeMatch ? '$' : '').'/u', $url, $match)) { |
|
275 | 275 | return false; |
276 | 276 | } |
277 | 277 | } catch (\Exception $e) { |