@@ -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 | |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | { |
66 | 66 | if (is_file($file)) { |
67 | 67 | $filename = $file; |
68 | - } elseif (is_file($this->path . $file . $this->ext)) { |
|
69 | - $filename = $this->path . $file . $this->ext; |
|
68 | + } elseif (is_file($this->path.$file.$this->ext)) { |
|
69 | + $filename = $this->path.$file.$this->ext; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | if (isset($filename)) { |
@@ -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 | |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | */ |
364 | 364 | public function domain(bool $port = false): string |
365 | 365 | { |
366 | - return $this->scheme() . '://' . $this->host($port); |
|
366 | + return $this->scheme().'://'.$this->host($port); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | if (!$root) { |
379 | 379 | $item = explode('.', $this->host()); |
380 | 380 | $count = count($item); |
381 | - $root = $count > 1 ? $item[$count - 2] . '.' . $item[$count - 1] : $item[0]; |
|
381 | + $root = $count > 1 ? $item[$count - 2].'.'.$item[$count - 1] : $item[0]; |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | return $root; |
@@ -466,14 +466,14 @@ discard block |
||
466 | 466 | } elseif ($this->server('REQUEST_URI')) { |
467 | 467 | $url = $this->server('REQUEST_URI'); |
468 | 468 | } elseif ($this->server('ORIG_PATH_INFO')) { |
469 | - $url = $this->server('ORIG_PATH_INFO') . (!empty($this->server('QUERY_STRING')) ? '?' . $this->server('QUERY_STRING') : ''); |
|
469 | + $url = $this->server('ORIG_PATH_INFO').(!empty($this->server('QUERY_STRING')) ? '?'.$this->server('QUERY_STRING') : ''); |
|
470 | 470 | } elseif (isset($_SERVER['argv'][1])) { |
471 | 471 | $url = $_SERVER['argv'][1]; |
472 | 472 | } else { |
473 | 473 | $url = ''; |
474 | 474 | } |
475 | 475 | |
476 | - return $complete ? $this->domain() . $url : $url; |
|
476 | + return $complete ? $this->domain().$url : $url; |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | /** |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | $this->baseUrl = strpos($str, '?') ? strstr($str, '?', true) : $str; |
502 | 502 | } |
503 | 503 | |
504 | - return $complete ? $this->domain() . $this->baseUrl : $this->baseUrl; |
|
504 | + return $complete ? $this->domain().$this->baseUrl : $this->baseUrl; |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | /** |
@@ -522,8 +522,8 @@ discard block |
||
522 | 522 | $url = $this->server('PHP_SELF'); |
523 | 523 | } elseif (basename($this->server('ORIG_SCRIPT_NAME')) === $script_name) { |
524 | 524 | $url = $this->server('ORIG_SCRIPT_NAME'); |
525 | - } elseif (($pos = strpos($this->server('PHP_SELF'), '/' . $script_name)) !== false) { |
|
526 | - $url = substr($this->server('SCRIPT_NAME'), 0, $pos) . '/' . $script_name; |
|
525 | + } elseif (($pos = strpos($this->server('PHP_SELF'), '/'.$script_name)) !== false) { |
|
526 | + $url = substr($this->server('SCRIPT_NAME'), 0, $pos).'/'.$script_name; |
|
527 | 527 | } elseif ($this->server('DOCUMENT_ROOT') && strpos($this->server('SCRIPT_FILENAME'), $this->server('DOCUMENT_ROOT')) === 0) { |
528 | 528 | $url = str_replace('\\', '/', str_replace($this->server('DOCUMENT_ROOT'), '', $this->server('SCRIPT_FILENAME'))); |
529 | 529 | } |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | $this->baseFile = $url; |
532 | 532 | } |
533 | 533 | |
534 | - return $complete ? $this->domain() . $this->baseFile : $this->baseFile; |
|
534 | + return $complete ? $this->domain().$this->baseFile : $this->baseFile; |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | /** |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | $this->root = rtrim($file, '/'); |
563 | 563 | } |
564 | 564 | |
565 | - return $complete ? $this->domain() . $this->root : $this->root; |
|
565 | + return $complete ? $this->domain().$this->root : $this->root; |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | /** |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | $root = strpos($base, '.') ? ltrim(dirname($base), DIRECTORY_SEPARATOR) : $base; |
577 | 577 | |
578 | 578 | if ('' != $root) { |
579 | - $root = '/' . ltrim($root, '/'); |
|
579 | + $root = '/'.ltrim($root, '/'); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | return $root; |
@@ -1317,7 +1317,7 @@ discard block |
||
1317 | 1317 | if (is_scalar($data)) { |
1318 | 1318 | $data = (string) $data; |
1319 | 1319 | } else { |
1320 | - throw new \InvalidArgumentException('variable type error:' . gettype($data)); |
|
1320 | + throw new \InvalidArgumentException('variable type error:'.gettype($data)); |
|
1321 | 1321 | } |
1322 | 1322 | break; |
1323 | 1323 | } |
@@ -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 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | foreach ($methods as $method) { |
188 | 188 | $name = $method->getName(); |
189 | 189 | if (0 === strpos($name, 'on')) { |
190 | - $this->listen($prefix . substr($name, 2), [$observer, $name]); |
|
190 | + $this->listen($prefix.substr($name, 2), [$observer, $name]); |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 |
@@ -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 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | if ($this->lang->defaultLangSet() != $langset) { |
49 | 49 | // 加载系统语言包 |
50 | 50 | $this->lang->load([ |
51 | - $this->app->getThinkPath() . 'lang' . DIRECTORY_SEPARATOR . $langset . '.php', |
|
51 | + $this->app->getThinkPath().'lang'.DIRECTORY_SEPARATOR.$langset.'.php', |
|
52 | 52 | ]); |
53 | 53 | |
54 | 54 | $this->app->LoadLangPack($langset); |
@@ -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 @@ |
||
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 | |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | |
89 | 89 | if (isset($key) && 200 == $response->getCode() && $response->isAllowCache()) { |
90 | 90 | $header = $response->getHeader(); |
91 | - $header['Cache-Control'] = 'max-age=' . $expire . ',must-revalidate'; |
|
92 | - $header['Last-Modified'] = gmdate('D, d M Y H:i:s') . ' GMT'; |
|
93 | - $header['Expires'] = gmdate('D, d M Y H:i:s', time() + $expire) . ' GMT'; |
|
91 | + $header['Cache-Control'] = 'max-age='.$expire.',must-revalidate'; |
|
92 | + $header['Last-Modified'] = gmdate('D, d M Y H:i:s').' GMT'; |
|
93 | + $header['Expires'] = gmdate('D, d M Y H:i:s', time() + $expire).' GMT'; |
|
94 | 94 | |
95 | 95 | $this->cache->tag($tag)->set($key, [$response->getContent(), $header, time()], $expire); |
96 | 96 | } |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | if (false !== strpos($key, ':')) { |
142 | 142 | $param = $request->param(); |
143 | 143 | foreach ($param as $item => $val) { |
144 | - if (is_string($val) && false !== strpos($key, ':' . $item)) { |
|
145 | - $key = str_replace(':' . $item, $val, $key); |
|
144 | + if (is_string($val) && false !== strpos($key, ':'.$item)) { |
|
145 | + $key = str_replace(':'.$item, $val, $key); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | } elseif (strpos($key, ']')) { |
149 | - if ('[' . $request->ext() . ']' == $key) { |
|
149 | + if ('['.$request->ext().']' == $key) { |
|
150 | 150 | // 缓存某个后缀的请求 |
151 | 151 | $key = md5($request->url()); |
152 | 152 | } 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; |
14 | 14 | |
@@ -162,13 +162,13 @@ discard block |
||
162 | 162 | */ |
163 | 163 | public function __construct(string $rootPath = '') |
164 | 164 | { |
165 | - $this->thinkPath = dirname(__DIR__) . DIRECTORY_SEPARATOR; |
|
166 | - $this->rootPath = $rootPath ? rtrim($rootPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR : $this->getDefaultRootPath(); |
|
167 | - $this->appPath = $this->rootPath . 'app' . DIRECTORY_SEPARATOR; |
|
168 | - $this->runtimePath = $this->rootPath . 'runtime' . DIRECTORY_SEPARATOR; |
|
165 | + $this->thinkPath = dirname(__DIR__).DIRECTORY_SEPARATOR; |
|
166 | + $this->rootPath = $rootPath ? rtrim($rootPath, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR : $this->getDefaultRootPath(); |
|
167 | + $this->appPath = $this->rootPath.'app'.DIRECTORY_SEPARATOR; |
|
168 | + $this->runtimePath = $this->rootPath.'runtime'.DIRECTORY_SEPARATOR; |
|
169 | 169 | |
170 | - if (is_file($this->appPath . 'provider.php')) { |
|
171 | - $this->bind(include $this->appPath . 'provider.php'); |
|
170 | + if (is_file($this->appPath.'provider.php')) { |
|
171 | + $this->bind(include $this->appPath.'provider.php'); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | static::setInstance($this); |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | public function getService($service) |
229 | 229 | { |
230 | 230 | $name = is_string($service) ? $service : get_class($service); |
231 | - return array_values(array_filter($this->services, function ($value) use ($name) { |
|
231 | + return array_values(array_filter($this->services, function($value) use ($name) { |
|
232 | 232 | return $value instanceof $name; |
233 | 233 | }, ARRAY_FILTER_USE_BOTH))[0] ?? null; |
234 | 234 | } |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | */ |
305 | 305 | public function getBasePath(): string |
306 | 306 | { |
307 | - return $this->rootPath . 'app' . DIRECTORY_SEPARATOR; |
|
307 | + return $this->rootPath.'app'.DIRECTORY_SEPARATOR; |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | */ |
363 | 363 | public function getConfigPath(): string |
364 | 364 | { |
365 | - return $this->rootPath . 'config' . DIRECTORY_SEPARATOR; |
|
365 | + return $this->rootPath.'config'.DIRECTORY_SEPARATOR; |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | /** |
@@ -408,8 +408,8 @@ discard block |
||
408 | 408 | $this->beginMem = memory_get_usage(); |
409 | 409 | |
410 | 410 | // 加载环境变量 |
411 | - if (is_file($this->rootPath . '.env')) { |
|
412 | - $this->env->load($this->rootPath . '.env'); |
|
411 | + if (is_file($this->rootPath.'.env')) { |
|
412 | + $this->env->load($this->rootPath.'.env'); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | $this->configExt = $this->env->get('config_ext', '.php'); |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | // 加载框架默认语言包 |
423 | 423 | $langSet = $this->lang->defaultLangSet(); |
424 | 424 | |
425 | - $this->lang->load($this->thinkPath . 'lang' . DIRECTORY_SEPARATOR . $langSet . '.php'); |
|
425 | + $this->lang->load($this->thinkPath.'lang'.DIRECTORY_SEPARATOR.$langSet.'.php'); |
|
426 | 426 | |
427 | 427 | // 加载应用默认语言包 |
428 | 428 | $this->loadLangPack($langSet); |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | } |
462 | 462 | |
463 | 463 | // 加载系统语言包 |
464 | - $files = glob($this->appPath . 'lang' . DIRECTORY_SEPARATOR . $langset . '.*'); |
|
464 | + $files = glob($this->appPath.'lang'.DIRECTORY_SEPARATOR.$langset.'.*'); |
|
465 | 465 | $this->lang->load($files); |
466 | 466 | |
467 | 467 | // 加载扩展(自定义)语言包 |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | */ |
480 | 480 | public function boot(): void |
481 | 481 | { |
482 | - array_walk($this->services, function ($service) { |
|
482 | + array_walk($this->services, function($service) { |
|
483 | 483 | $this->bootService($service); |
484 | 484 | }); |
485 | 485 | } |
@@ -493,30 +493,30 @@ discard block |
||
493 | 493 | { |
494 | 494 | $appPath = $this->getAppPath(); |
495 | 495 | |
496 | - if (is_file($appPath . 'common.php')) { |
|
497 | - include_once $appPath . 'common.php'; |
|
496 | + if (is_file($appPath.'common.php')) { |
|
497 | + include_once $appPath.'common.php'; |
|
498 | 498 | } |
499 | 499 | |
500 | - include_once $this->thinkPath . 'helper.php'; |
|
500 | + include_once $this->thinkPath.'helper.php'; |
|
501 | 501 | |
502 | 502 | $configPath = $this->getConfigPath(); |
503 | 503 | |
504 | 504 | $files = []; |
505 | 505 | |
506 | 506 | if (is_dir($configPath)) { |
507 | - $files = glob($configPath . '*' . $this->configExt); |
|
507 | + $files = glob($configPath.'*'.$this->configExt); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | foreach ($files as $file) { |
511 | 511 | $this->config->load($file, pathinfo($file, PATHINFO_FILENAME)); |
512 | 512 | } |
513 | 513 | |
514 | - if (is_file($appPath . 'event.php')) { |
|
515 | - $this->loadEvent(include $appPath . 'event.php'); |
|
514 | + if (is_file($appPath.'event.php')) { |
|
515 | + $this->loadEvent(include $appPath.'event.php'); |
|
516 | 516 | } |
517 | 517 | |
518 | - if (is_file($appPath . 'service.php')) { |
|
519 | - $services = include $appPath . 'service.php'; |
|
518 | + if (is_file($appPath.'service.php')) { |
|
519 | + $services = include $appPath.'service.php'; |
|
520 | 520 | foreach ($services as $service) { |
521 | 521 | $this->register($service); |
522 | 522 | } |
@@ -581,9 +581,9 @@ discard block |
||
581 | 581 | $name = str_replace(['/', '.'], '\\', $name); |
582 | 582 | $array = explode('\\', $name); |
583 | 583 | $class = Str::studly(array_pop($array)); |
584 | - $path = $array ? implode('\\', $array) . '\\' : ''; |
|
584 | + $path = $array ? implode('\\', $array).'\\' : ''; |
|
585 | 585 | |
586 | - return $this->namespace . '\\' . $layer . '\\' . $path . $class; |
|
586 | + return $this->namespace.'\\'.$layer.'\\'.$path.$class; |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | /** |
@@ -602,6 +602,6 @@ discard block |
||
602 | 602 | */ |
603 | 603 | protected function getDefaultRootPath(): string |
604 | 604 | { |
605 | - return dirname($this->thinkPath, 4) . DIRECTORY_SEPARATOR; |
|
605 | + return dirname($this->thinkPath, 4).DIRECTORY_SEPARATOR; |
|
606 | 606 | } |
607 | 607 | } |