From 00de83c5647c24067c096028478386a4e3158714 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 24 Jul 2024 11:00:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=B7=AF=E7=94=B1=E5=88=86?= =?UTF-8?q?=E7=BB=84=E7=9A=84=E8=B0=83=E5=BA=A6=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/think/Cookie.php | 4 ++-- src/think/Route.php | 12 ++++++------ src/think/route/RuleGroup.php | 12 +++++------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/think/Cookie.php b/src/think/Cookie.php index 41eeac36ba..1d024a584f 100644 --- a/src/think/Cookie.php +++ b/src/think/Cookie.php @@ -8,7 +8,7 @@ // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare(strict_types=1); +declare (strict_types = 1); namespace think; @@ -51,7 +51,7 @@ class Cookie */ public function __construct(protected Request $request, array $config = []) { - $this->config = array_merge($this->config, array_change_key_case($config)); + $this->config = array_merge($this->config, array_change_key_case($config)); } public static function __make(Request $request, Config $config) diff --git a/src/think/Route.php b/src/think/Route.php index b891256bc5..c91bc67e47 100644 --- a/src/think/Route.php +++ b/src/think/Route.php @@ -8,7 +8,7 @@ // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare(strict_types=1); +declare (strict_types = 1); namespace think; @@ -285,7 +285,7 @@ public function option(array $option) * @param mixed $rule 路由规则 * @return Domain */ - public function domain(string|array $name, $rule = null): Domain + public function domain(string | array $name, $rule = null): Domain { // 支持多个域名使用相同路由规则 $domainName = is_array($name) ? array_shift($name) : $name; @@ -513,7 +513,7 @@ public function setCrossDomainRule(Rule $rule) * @param mixed $route 分组路由 * @return RuleGroup */ - public function group(string|Closure $name, $route = null): RuleGroup + public function group(string | Closure $name, $route = null): RuleGroup { if ($name instanceof Closure) { $route = $name; @@ -688,7 +688,7 @@ public function redirect(string $rule, string $route = '', int $status = 301): R * @param array|bool $resource 资源 * @return $this */ - public function rest(string|array $name, array|bool $resource = []) + public function rest(string | array $name, array | bool $resource = []) { if (is_array($name)) { $this->rest = $resource ? $name : array_merge($this->rest, $name); @@ -721,7 +721,7 @@ public function getRest(string $name = null) * @param string $method 请求类型 * @return RuleItem */ - public function miss(string|Closure $route, string $method = '*'): RuleItem + public function miss(string | Closure $route, string $method = '*'): RuleItem { return $this->group->miss($route, $method); } @@ -732,7 +732,7 @@ public function miss(string|Closure $route, string $method = '*'): RuleItem * @param Closure|bool $withRoute * @return Response */ - public function dispatch(Request $request, Closure|bool $withRoute = true) + public function dispatch(Request $request, Closure | bool $withRoute = true) { $this->request = $request; $this->host = $this->request->host(true); diff --git a/src/think/route/RuleGroup.php b/src/think/route/RuleGroup.php index b678d3266e..0286ba35c1 100644 --- a/src/think/route/RuleGroup.php +++ b/src/think/route/RuleGroup.php @@ -8,7 +8,7 @@ // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare(strict_types=1); +declare (strict_types = 1); namespace think\route; @@ -170,9 +170,7 @@ public function check(Request $request, string $url, bool $completeMatch = false } } - if (!empty($option['dispatcher'])) { - $result = $this->parseRule($request, '', $option['dispatcher'], $url, $option); - } elseif ($miss = $this->getMissRule($method)) { + if ($miss = $this->getMissRule($method)) { // 未匹配所有路由的路由规则处理 $result = $miss->parseRule($request, '', $miss->getRoute(), $url, $miss->getOption()); } else { @@ -355,11 +353,11 @@ protected function checkMergeRuleRegex(Request $request, array &$rules, string $ * @param string $method 请求类型 * @return RuleItem */ - public function miss(string|Closure $route, string $method = '*'): RuleItem + public function miss(string | Closure $route, string $method = '*'): RuleItem { // 创建路由规则实例 - $method = strtolower($method); - $ruleItem = new RuleItem($this->router, $this, null, '', $route, $method); + $method = strtolower($method); + $ruleItem = new RuleItem($this->router, $this, null, '', $route, $method); $this->miss[$method] = $ruleItem->setMiss();