@@ -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 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | } |
95 | 95 | |
96 | 96 | if ($this->parent && $this->parent->getFullName()) { |
97 | - $this->fullName = $this->parent->getFullName() . ($this->name ? '/' . $this->name : ''); |
|
97 | + $this->fullName = $this->parent->getFullName().($this->name ? '/'.$this->name : ''); |
|
98 | 98 | } else { |
99 | 99 | $this->fullName = $this->name; |
100 | 100 | } |
@@ -278,14 +278,14 @@ discard block |
||
278 | 278 | protected function checkMergeRuleRegex(Request $request, array &$rules, string $url, bool $completeMatch) |
279 | 279 | { |
280 | 280 | $depr = $this->router->config('pathinfo_depr'); |
281 | - $url = $depr . str_replace('|', $depr, $url); |
|
281 | + $url = $depr.str_replace('|', $depr, $url); |
|
282 | 282 | $regex = []; |
283 | 283 | $items = []; |
284 | 284 | |
285 | 285 | foreach ($rules as $key => $val) { |
286 | 286 | $item = $val[1]; |
287 | 287 | if ($item instanceof RuleItem) { |
288 | - $rule = $depr . str_replace('/', $depr, $item->getRule()); |
|
288 | + $rule = $depr.str_replace('/', $depr, $item->getRule()); |
|
289 | 289 | if ($depr == $rule && $depr != $url) { |
290 | 290 | unset($rules[$key]); |
291 | 291 | continue; |
@@ -302,21 +302,21 @@ discard block |
||
302 | 302 | continue; |
303 | 303 | } |
304 | 304 | |
305 | - $slash = preg_quote('/-' . $depr, '/'); |
|
305 | + $slash = preg_quote('/-'.$depr, '/'); |
|
306 | 306 | |
307 | - if ($matchRule = preg_split('/[' . $slash . ']<\w+\??>/', $rule, 2)) { |
|
307 | + if ($matchRule = preg_split('/['.$slash.']<\w+\??>/', $rule, 2)) { |
|
308 | 308 | if ($matchRule[0] && 0 !== strncasecmp($rule, $url, strlen($matchRule[0]))) { |
309 | 309 | unset($rules[$key]); |
310 | 310 | continue; |
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | - if (preg_match_all('/[' . $slash . ']?<?\w+\??>?/', $rule, $matches)) { |
|
314 | + if (preg_match_all('/['.$slash.']?<?\w+\??>?/', $rule, $matches)) { |
|
315 | 315 | unset($rules[$key]); |
316 | 316 | $pattern = array_merge($this->getPattern(), $item->getPattern()); |
317 | 317 | $option = array_merge($this->getOption(), $item->getOption()); |
318 | 318 | |
319 | - $regex[$key] = $this->buildRuleRegex($rule, $matches[0], $pattern, $option, $complete, '_THINK_' . $key); |
|
319 | + $regex[$key] = $this->buildRuleRegex($rule, $matches[0], $pattern, $option, $complete, '_THINK_'.$key); |
|
320 | 320 | $items[$key] = $item; |
321 | 321 | } |
322 | 322 | } |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | } |
328 | 328 | |
329 | 329 | try { |
330 | - $result = preg_match('/^(?:' . implode('|', $regex) . ')/u', $url, $match); |
|
330 | + $result = preg_match('/^(?:'.implode('|', $regex).')/u', $url, $match); |
|
331 | 331 | } catch (\Exception $e) { |
332 | 332 | throw new Exception('route pattern error'); |
333 | 333 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | |
345 | 345 | if (!isset($pos)) { |
346 | 346 | foreach ($regex as $key => $item) { |
347 | - if (0 === strpos(str_replace(['\/', '\-', '\\' . $depr], ['/', '-', $depr], $item), $match[0])) { |
|
347 | + if (0 === strpos(str_replace(['\/', '\-', '\\'.$depr], ['/', '-', $depr], $item), $match[0])) { |
|
348 | 348 | $pos = $key; |
349 | 349 | break; |
350 | 350 | } |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | * @access public |
374 | 374 | * @return RuleItem|null |
375 | 375 | */ |
376 | - public function getMissRule(): ? RuleItem |
|
376 | + public function getMissRule(): ? RuleItem |
|
377 | 377 | { |
378 | 378 | return $this->miss; |
379 | 379 | } |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | public function prefix(string $prefix) |
460 | 460 | { |
461 | 461 | if ($this->parent && $this->parent->getOption('prefix')) { |
462 | - $prefix = $this->parent->getOption('prefix') . $prefix; |
|
462 | + $prefix = $this->parent->getOption('prefix').$prefix; |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | return $this->setOption('prefix', $prefix); |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | return $this->rules; |
499 | 499 | } |
500 | 500 | |
501 | - return array_filter($this->rules, function ($item) use ($method) { |
|
501 | + return array_filter($this->rules, function($item) use ($method) { |
|
502 | 502 | return $method == $item[0] || $item[0] == '*'; |
503 | 503 | }); |
504 | 504 | } |