Skip to content

Commit

Permalink
修正路由分组的调度检查
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Jul 24, 2024
1 parent adfc0c2 commit 00de83c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/think/Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
declare(strict_types=1);
declare (strict_types = 1);

namespace think;

Expand Down Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions src/think/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
declare(strict_types=1);
declare (strict_types = 1);

namespace think;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
Expand Down
12 changes: 5 additions & 7 deletions src/think/route/RuleGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
declare(strict_types=1);
declare (strict_types = 1);

namespace think\route;

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 00de83c

Please # to comment.