@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | protected function getAvailablePageWrapper(string $url, string $page): string |
141 | 141 | { |
142 | - return '<li><a href="' . htmlentities($url) . '">' . $page . '</a></li>'; |
|
142 | + return '<li><a href="'.htmlentities($url).'">'.$page.'</a></li>'; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | protected function getDisabledTextWrapper(string $text): string |
152 | 152 | { |
153 | - return '<li class="disabled"><span>' . $text . '</span></li>'; |
|
153 | + return '<li class="disabled"><span>'.$text.'</span></li>'; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | protected function getActivePageWrapper(string $text): string |
163 | 163 | { |
164 | - return '<li class="active"><span>' . $text . '</span></li>'; |
|
164 | + return '<li class="active"><span>'.$text.'</span></li>'; |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -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 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | { |
87 | 87 | $target = $this->getTargetFile($directory, $name); |
88 | 88 | |
89 | - set_error_handler(function ($type, $msg) use (&$error) { |
|
89 | + set_error_handler(function($type, $msg) use (&$error) { |
|
90 | 90 | $error = $msg; |
91 | 91 | }); |
92 | 92 | $renamed = rename($this->getPathname(), $target); |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | throw new FileException(sprintf('Unable to write in the "%s" directory', $directory)); |
117 | 117 | } |
118 | 118 | |
119 | - $target = rtrim($directory, '/\\') . \DIRECTORY_SEPARATOR . (null === $name ? $this->getBasename() : $this->getName($name)); |
|
119 | + $target = rtrim($directory, '/\\').\DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : $this->getName($name)); |
|
120 | 120 | |
121 | 121 | return new self($target, false); |
122 | 122 | } |
@@ -159,18 +159,18 @@ discard block |
||
159 | 159 | switch (true) { |
160 | 160 | case in_array($rule, hash_algos()): |
161 | 161 | $hash = $this->hash($rule); |
162 | - $this->hashName = substr($hash, 0, 2) . DIRECTORY_SEPARATOR . substr($hash, 2); |
|
162 | + $this->hashName = substr($hash, 0, 2).DIRECTORY_SEPARATOR.substr($hash, 2); |
|
163 | 163 | break; |
164 | 164 | case is_callable($rule): |
165 | 165 | $this->hashName = call_user_func($rule); |
166 | 166 | break; |
167 | 167 | default: |
168 | - $this->hashName = date('Ymd') . DIRECTORY_SEPARATOR . md5((string) microtime(true)); |
|
168 | + $this->hashName = date('Ymd').DIRECTORY_SEPARATOR.md5((string) microtime(true)); |
|
169 | 169 | break; |
170 | 170 | } |
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
174 | - return $this->hashName . '.' . $this->extension(); |
|
174 | + return $this->hashName.'.'.$this->extension(); |
|
175 | 175 | } |
176 | 176 | } |
@@ -8,7 +8,7 @@ |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: yunwuxin <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think; |
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 | |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function __construct(string $rootPath = '') |
110 | 110 | { |
111 | - $this->thinkPath = dirname(__DIR__) . DIRECTORY_SEPARATOR; |
|
112 | - $this->rootPath = $rootPath ? rtrim($rootPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR : $this->getDefaultRootPath(); |
|
113 | - $this->appPath = $this->rootPath . 'app' . DIRECTORY_SEPARATOR; |
|
114 | - $this->runtimePath = $this->rootPath . 'runtime' . DIRECTORY_SEPARATOR; |
|
111 | + $this->thinkPath = dirname(__DIR__).DIRECTORY_SEPARATOR; |
|
112 | + $this->rootPath = $rootPath ? rtrim($rootPath, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR : $this->getDefaultRootPath(); |
|
113 | + $this->appPath = $this->rootPath.'app'.DIRECTORY_SEPARATOR; |
|
114 | + $this->runtimePath = $this->rootPath.'runtime'.DIRECTORY_SEPARATOR; |
|
115 | 115 | |
116 | - if (is_file($this->appPath . 'provider.php')) { |
|
117 | - $this->bind(include $this->appPath . 'provider.php'); |
|
116 | + if (is_file($this->appPath.'provider.php')) { |
|
117 | + $this->bind(include $this->appPath.'provider.php'); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | static::setInstance($this); |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | public function getService($service) |
175 | 175 | { |
176 | 176 | $name = is_string($service) ? $service : get_class($service); |
177 | - return array_values(array_filter($this->services, function ($value) use ($name) { |
|
177 | + return array_values(array_filter($this->services, function($value) use ($name) { |
|
178 | 178 | return $value instanceof $name; |
179 | 179 | }, ARRAY_FILTER_USE_BOTH))[0] ?? null; |
180 | 180 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | */ |
251 | 251 | public function getBasePath(): string |
252 | 252 | { |
253 | - return $this->rootPath . 'app' . DIRECTORY_SEPARATOR; |
|
253 | + return $this->rootPath.'app'.DIRECTORY_SEPARATOR; |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | */ |
309 | 309 | public function getConfigPath(): string |
310 | 310 | { |
311 | - return $this->rootPath . 'config' . DIRECTORY_SEPARATOR; |
|
311 | + return $this->rootPath.'config'.DIRECTORY_SEPARATOR; |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | /** |
@@ -354,8 +354,8 @@ discard block |
||
354 | 354 | $this->beginMem = memory_get_usage(); |
355 | 355 | |
356 | 356 | // 加载环境变量 |
357 | - if (is_file($this->rootPath . '.env')) { |
|
358 | - $this->env->load($this->rootPath . '.env'); |
|
357 | + if (is_file($this->rootPath.'.env')) { |
|
358 | + $this->env->load($this->rootPath.'.env'); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | $this->configExt = $this->env->get('config_ext', '.php'); |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | // 加载框架默认语言包 |
369 | 369 | $langSet = $this->lang->defaultLangSet(); |
370 | 370 | |
371 | - $this->lang->load($this->thinkPath . 'lang' . DIRECTORY_SEPARATOR . $langSet . '.php'); |
|
371 | + $this->lang->load($this->thinkPath.'lang'.DIRECTORY_SEPARATOR.$langSet.'.php'); |
|
372 | 372 | |
373 | 373 | // 加载应用默认语言包 |
374 | 374 | $this->loadLangPack($langSet); |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | } |
408 | 408 | |
409 | 409 | // 加载系统语言包 |
410 | - $files = glob($this->appPath . 'lang' . DIRECTORY_SEPARATOR . $langset . '.*'); |
|
410 | + $files = glob($this->appPath.'lang'.DIRECTORY_SEPARATOR.$langset.'.*'); |
|
411 | 411 | $this->lang->load($files); |
412 | 412 | |
413 | 413 | // 加载扩展(自定义)语言包 |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | */ |
426 | 426 | public function boot(): void |
427 | 427 | { |
428 | - array_walk($this->services, function ($service) { |
|
428 | + array_walk($this->services, function($service) { |
|
429 | 429 | $this->bootService($service); |
430 | 430 | }); |
431 | 431 | } |
@@ -439,30 +439,30 @@ discard block |
||
439 | 439 | { |
440 | 440 | $appPath = $this->getAppPath(); |
441 | 441 | |
442 | - if (is_file($appPath . 'common.php')) { |
|
443 | - include $appPath . 'common.php'; |
|
442 | + if (is_file($appPath.'common.php')) { |
|
443 | + include $appPath.'common.php'; |
|
444 | 444 | } |
445 | 445 | |
446 | - include $this->thinkPath . 'helper.php'; |
|
446 | + include $this->thinkPath.'helper.php'; |
|
447 | 447 | |
448 | 448 | $configPath = $this->getConfigPath(); |
449 | 449 | |
450 | 450 | $files = []; |
451 | 451 | |
452 | 452 | if (is_dir($configPath)) { |
453 | - $files = glob($configPath . '*' . $this->configExt); |
|
453 | + $files = glob($configPath.'*'.$this->configExt); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | foreach ($files as $file) { |
457 | 457 | $this->config->load($file, pathinfo($file, PATHINFO_FILENAME)); |
458 | 458 | } |
459 | 459 | |
460 | - if (is_file($appPath . 'event.php')) { |
|
461 | - $this->loadEvent(include $appPath . 'event.php'); |
|
460 | + if (is_file($appPath.'event.php')) { |
|
461 | + $this->loadEvent(include $appPath.'event.php'); |
|
462 | 462 | } |
463 | 463 | |
464 | - if (is_file($appPath . 'service.php')) { |
|
465 | - $services = include $appPath . 'service.php'; |
|
464 | + if (is_file($appPath.'service.php')) { |
|
465 | + $services = include $appPath.'service.php'; |
|
466 | 466 | foreach ($services as $service) { |
467 | 467 | $this->register($service); |
468 | 468 | } |
@@ -527,9 +527,9 @@ discard block |
||
527 | 527 | $name = str_replace(['/', '.'], '\\', $name); |
528 | 528 | $array = explode('\\', $name); |
529 | 529 | $class = self::parseName(array_pop($array), 1); |
530 | - $path = $array ? implode('\\', $array) . '\\' : ''; |
|
530 | + $path = $array ? implode('\\', $array).'\\' : ''; |
|
531 | 531 | |
532 | - return $this->namespace . '\\' . $layer . '\\' . $path . $class; |
|
532 | + return $this->namespace.'\\'.$layer.'\\'.$path.$class; |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | /** |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | { |
551 | 551 | $path = dirname(dirname(dirname(dirname($this->thinkPath)))); |
552 | 552 | |
553 | - return $path . DIRECTORY_SEPARATOR; |
|
553 | + return $path.DIRECTORY_SEPARATOR; |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | /** |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | public static function parseName(string $name = null, int $type = 0, bool $ucfirst = true): string |
566 | 566 | { |
567 | 567 | if ($type) { |
568 | - $name = preg_replace_callback('/_([a-zA-Z])/', function ($match) { |
|
568 | + $name = preg_replace_callback('/_([a-zA-Z])/', function($match) { |
|
569 | 569 | return strtoupper($match[1]); |
570 | 570 | }, $name); |
571 | 571 | return $ucfirst ? ucfirst($name) : lcfirst($name); |
@@ -596,13 +596,13 @@ discard block |
||
596 | 596 | */ |
597 | 597 | public static function factory(string $name, string $namespace = '', ...$args) |
598 | 598 | { |
599 | - $class = false !== strpos($name, '\\') ? $name : $namespace . ucwords($name); |
|
599 | + $class = false !== strpos($name, '\\') ? $name : $namespace.ucwords($name); |
|
600 | 600 | |
601 | 601 | if (class_exists($class)) { |
602 | 602 | return Container::getInstance()->invokeClass($class, $args); |
603 | 603 | } |
604 | 604 | |
605 | - throw new ClassNotFoundException('class not exists:' . $class, $class); |
|
605 | + throw new ClassNotFoundException('class not exists:'.$class, $class); |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | /** |
@@ -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\route; |
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\route; |
14 | 14 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $this->parseUrlParams($array[2], $param); |
157 | 157 | } |
158 | 158 | |
159 | - return new CallbackDispatch($request, $this, [$namespace . '\\' . App::parseName($class, 1), $method], $param); |
|
159 | + return new CallbackDispatch($request, $this, [$namespace.'\\'.App::parseName($class, 1), $method], $param); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $this->parseUrlParams($array[1], $param); |
178 | 178 | } |
179 | 179 | |
180 | - return new ControllerDispatch($request, $this, $controller . '/' . $action, $param); |
|
180 | + return new ControllerDispatch($request, $this, $controller.'/'.$action, $param); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | } |
@@ -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\route; |
14 | 14 | |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | { |
603 | 603 | if (is_string($route) && isset($option['prefix'])) { |
604 | 604 | // 路由地址前缀 |
605 | - $route = $option['prefix'] . $route; |
|
605 | + $route = $option['prefix'].$route; |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | // 替换路由地址中的变量 |
@@ -610,10 +610,10 @@ discard block |
||
610 | 610 | $search = $replace = []; |
611 | 611 | |
612 | 612 | foreach ($matches as $key => $value) { |
613 | - $search[] = '<' . $key . '>'; |
|
613 | + $search[] = '<'.$key.'>'; |
|
614 | 614 | $replace[] = $value; |
615 | 615 | |
616 | - $search[] = ':' . $key; |
|
616 | + $search[] = ':'.$key; |
|
617 | 617 | $replace[] = $value; |
618 | 618 | } |
619 | 619 | |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | // AJAX PJAX 请求检查 |
719 | 719 | foreach (['ajax', 'pjax', 'json'] as $item) { |
720 | 720 | if (isset($option[$item])) { |
721 | - $call = 'is' . $item; |
|
721 | + $call = 'is'.$item; |
|
722 | 722 | if ($option[$item] && !$request->$call() || !$option[$item] && $request->$call()) { |
723 | 723 | return false; |
724 | 724 | } |
@@ -726,8 +726,8 @@ discard block |
||
726 | 726 | } |
727 | 727 | |
728 | 728 | // 伪静态后缀检测 |
729 | - if ($request->url() != '/' && ((isset($option['ext']) && false === stripos('|' . $option['ext'] . '|', '|' . $request->ext() . '|')) |
|
730 | - || (isset($option['deny_ext']) && false !== stripos('|' . $option['deny_ext'] . '|', '|' . $request->ext() . '|')))) { |
|
729 | + if ($request->url() != '/' && ((isset($option['ext']) && false === stripos('|'.$option['ext'].'|', '|'.$request->ext().'|')) |
|
730 | + || (isset($option['deny_ext']) && false !== stripos('|'.$option['deny_ext'].'|', '|'.$request->ext().'|')))) { |
|
731 | 731 | return false; |
732 | 732 | } |
733 | 733 | |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | protected function parseUrlParams(string $url, array &$var = []): void |
765 | 765 | { |
766 | 766 | if ($url) { |
767 | - preg_replace_callback('/(\w+)\|([^\|]+)/', function ($match) use (&$var) { |
|
767 | + preg_replace_callback('/(\w+)\|([^\|]+)/', function($match) use (&$var) { |
|
768 | 768 | $var[$match[1]] = strip_tags($match[2]); |
769 | 769 | }, $url); |
770 | 770 | } |
@@ -826,7 +826,7 @@ discard block |
||
826 | 826 | $regex .= '\/'; |
827 | 827 | } |
828 | 828 | |
829 | - return $regex . ($completeMatch ? '$' : ''); |
|
829 | + return $regex.($completeMatch ? '$' : ''); |
|
830 | 830 | } |
831 | 831 | |
832 | 832 | /** |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | $slash = substr($name, 0, 1); |
844 | 844 | |
845 | 845 | if (in_array($slash, ['/', '-'])) { |
846 | - $prefix = '\\' . $slash; |
|
846 | + $prefix = '\\'.$slash; |
|
847 | 847 | $name = substr($name, 1); |
848 | 848 | $slash = substr($name, 0, 1); |
849 | 849 | } else { |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | } |
852 | 852 | |
853 | 853 | if ('<' != $slash) { |
854 | - return $prefix . preg_quote($name, '/'); |
|
854 | + return $prefix.preg_quote($name, '/'); |
|
855 | 855 | } |
856 | 856 | |
857 | 857 | if (strpos($name, '?')) { |
@@ -870,7 +870,7 @@ discard block |
||
870 | 870 | $nameRule = $this->router->config('default_route_pattern'); |
871 | 871 | } |
872 | 872 | |
873 | - return '(' . $prefix . '(?<' . $name . $suffix . '>' . $nameRule . '))' . $optional; |
|
873 | + return '('.$prefix.'(?<'.$name.$suffix.'>'.$nameRule.'))'.$optional; |
|
874 | 874 | } |
875 | 875 | |
876 | 876 | /** |
@@ -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\route; |
14 | 14 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | $val = []; |
133 | 133 | |
134 | 134 | foreach (['method', 'rule', 'name', 'route', 'domain', 'pattern', 'option'] as $param) { |
135 | - $call = 'get' . $param; |
|
135 | + $call = 'get'.$param; |
|
136 | 136 | $val[$param] = $item->$call(); |
137 | 137 | } |
138 | 138 |
@@ -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\route; |
14 | 14 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | } |
173 | 173 | } |
174 | 174 | } elseif (false === strpos($domain, '.') && 0 !== strpos($domain, $rootDomain)) { |
175 | - $domain .= '.' . $rootDomain; |
|
175 | + $domain .= '.'.$rootDomain; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | if (false !== strpos($domain, '://')) { |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | $scheme = $request->isSsl() ? 'https://' : 'http://'; |
182 | 182 | } |
183 | 183 | |
184 | - return $scheme . $domain; |
|
184 | + return $scheme.$domain; |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | - return (empty($suffix) || 0 === strpos($suffix, '.')) ? (string) $suffix : '.' . $suffix; |
|
203 | + return (empty($suffix) || 0 === strpos($suffix, '.')) ? (string) $suffix : '.'.$suffix; |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | $controller = App::parseName($controller); |
243 | 243 | } |
244 | 244 | |
245 | - $url = $controller . '/' . $action; |
|
245 | + $url = $controller.'/'.$action; |
|
246 | 246 | |
247 | 247 | if ($app && $this->app->config->get('app.auto_multi_app')) { |
248 | 248 | $bind = $this->app->config->get('app.domain_bind', []); |
@@ -252,9 +252,9 @@ discard block |
||
252 | 252 | $map = $this->app->config->get('app.app_map', []); |
253 | 253 | |
254 | 254 | if ($key = array_search($app, $map)) { |
255 | - $url = $key . '/' . $url; |
|
255 | + $url = $key.'/'.$url; |
|
256 | 256 | } else { |
257 | - $url = $app . '/' . $url; |
|
257 | + $url = $app.'/'.$url; |
|
258 | 258 | } |
259 | 259 | } |
260 | 260 | } |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | } |
320 | 320 | |
321 | 321 | if (!in_array($request->port(), [80, 443])) { |
322 | - $domain .= ':' . $request->port(); |
|
322 | + $domain .= ':'.$request->port(); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | if (empty($pattern)) { |
@@ -330,12 +330,12 @@ discard block |
||
330 | 330 | |
331 | 331 | foreach ($pattern as $key => $val) { |
332 | 332 | if (isset($vars[$key])) { |
333 | - $url = str_replace(['[:' . $key . ']', '<' . $key . '?>', ':' . $key, '<' . $key . '>'], $type ? $vars[$key] : urlencode((string) $vars[$key]), $url); |
|
333 | + $url = str_replace(['[:'.$key.']', '<'.$key.'?>', ':'.$key, '<'.$key.'>'], $type ? $vars[$key] : urlencode((string) $vars[$key]), $url); |
|
334 | 334 | unset($vars[$key]); |
335 | 335 | $url = str_replace(['/?', '-?'], ['/', '-'], $url); |
336 | 336 | $result = [rtrim($url, '?/-'), $domain, $suffix]; |
337 | 337 | } elseif (2 == $val) { |
338 | - $url = str_replace(['/[:' . $key . ']', '[:' . $key . ']', '<' . $key . '?>'], '', $url); |
|
338 | + $url = str_replace(['/[:'.$key.']', '[:'.$key.']', '<'.$key.'?>'], '', $url); |
|
339 | 339 | $url = str_replace(['/?', '-?'], ['/', '-'], $url); |
340 | 340 | $result = [rtrim($url, '?/-'), $domain, $suffix]; |
341 | 341 | } else { |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | if (0 === strpos($url, '[') && $pos = strpos($url, ']')) { |
364 | 364 | // [name] 表示使用路由命名标识生成URL |
365 | 365 | $name = substr($url, 1, $pos - 1); |
366 | - $url = 'name' . substr($url, $pos + 1); |
|
366 | + $url = 'name'.substr($url, $pos + 1); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | if (false === strpos($url, '://') && 0 !== strpos($url, '/')) { |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | } |
391 | 391 | |
392 | 392 | if ($url) { |
393 | - $checkName = isset($name) ? $name : $url . (isset($info['query']) ? '?' . $info['query'] : ''); |
|
393 | + $checkName = isset($name) ? $name : $url.(isset($info['query']) ? '?'.$info['query'] : ''); |
|
394 | 394 | $checkDomain = $domain && is_string($domain) ? $domain : null; |
395 | 395 | |
396 | 396 | $rule = $this->route->getName($checkName, $checkDomain); |
@@ -417,10 +417,10 @@ discard block |
||
417 | 417 | } |
418 | 418 | |
419 | 419 | if ($request->app() && $this->app->config->get('app.auto_multi_app') && !$this->app->http->isBindDomain()) { |
420 | - $url = $request->app() . '/' . $url; |
|
420 | + $url = $request->app().'/'.$url; |
|
421 | 421 | } |
422 | 422 | } elseif (!empty($rule) && isset($name)) { |
423 | - throw new \InvalidArgumentException('route name not exists:' . $name); |
|
423 | + throw new \InvalidArgumentException('route name not exists:'.$name); |
|
424 | 424 | } else { |
425 | 425 | // 检测URL绑定 |
426 | 426 | $bind = $this->route->getDomainBind($domain && is_string($domain) ? $domain : null); |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | $file = str_replace('\\', '/', dirname($file)); |
459 | 459 | } |
460 | 460 | |
461 | - $url = rtrim($file, '/') . '/' . $url; |
|
461 | + $url = rtrim($file, '/').'/'.$url; |
|
462 | 462 | |
463 | 463 | // URL后缀 |
464 | 464 | if ('/' == substr($url, -1) || '' == $url) { |
@@ -468,32 +468,32 @@ discard block |
||
468 | 468 | } |
469 | 469 | |
470 | 470 | // 锚点 |
471 | - $anchor = !empty($anchor) ? '#' . $anchor : ''; |
|
471 | + $anchor = !empty($anchor) ? '#'.$anchor : ''; |
|
472 | 472 | |
473 | 473 | // 参数组装 |
474 | 474 | if (!empty($vars)) { |
475 | 475 | // 添加参数 |
476 | 476 | if ($this->route->config('url_common_param')) { |
477 | 477 | $vars = http_build_query($vars); |
478 | - $url .= $suffix . '?' . $vars . $anchor; |
|
478 | + $url .= $suffix.'?'.$vars.$anchor; |
|
479 | 479 | } else { |
480 | 480 | foreach ($vars as $var => $val) { |
481 | 481 | if ('' !== $val) { |
482 | - $url .= $depr . $var . $depr . urlencode((string) $val); |
|
482 | + $url .= $depr.$var.$depr.urlencode((string) $val); |
|
483 | 483 | } |
484 | 484 | } |
485 | 485 | |
486 | - $url .= $suffix . $anchor; |
|
486 | + $url .= $suffix.$anchor; |
|
487 | 487 | } |
488 | 488 | } else { |
489 | - $url .= $suffix . $anchor; |
|
489 | + $url .= $suffix.$anchor; |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | // 检测域名 |
493 | 493 | $domain = $this->parseDomain($url, $domain); |
494 | 494 | |
495 | 495 | // URL组装 |
496 | - return $domain . rtrim($this->root, '/') . '/' . ltrim($url, '/'); |
|
496 | + return $domain.rtrim($this->root, '/').'/'.ltrim($url, '/'); |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | public function __toString() |