@@ -7,7 +7,7 @@ |
||
| 7 | 7 | * @package Phoole\Route |
| 8 | 8 | * @copyright Copyright (c) 2019 Hong Zhang |
| 9 | 9 | */ |
| 10 | -declare(strict_types = 1); |
|
| 10 | +declare(strict_types=1); |
|
| 11 | 11 | |
| 12 | 12 | namespace Phoole\Route\Parser; |
| 13 | 13 | |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * @package Phoole\Route |
| 8 | 8 | * @copyright Copyright (c) 2019 Hong Zhang |
| 9 | 9 | */ |
| 10 | -declare(strict_types = 1); |
|
| 10 | +declare(strict_types=1); |
|
| 11 | 11 | |
| 12 | 12 | namespace Phoole\Route\Parser; |
| 13 | 13 | |
@@ -73,13 +73,13 @@ discard block |
||
| 73 | 73 | * @var string[] |
| 74 | 74 | */ |
| 75 | 75 | protected $shortcuts = [ |
| 76 | - ':d}' => ':[0-9]++}', // digit only |
|
| 77 | - ':l}' => ':[a-z]++}', // lower case |
|
| 78 | - ':u}' => ':[A-Z]++}', // upper case |
|
| 79 | - ':a}' => ':[0-9a-zA-Z]++}', // alphanumeric |
|
| 76 | + ':d}' => ':[0-9]++}', // digit only |
|
| 77 | + ':l}' => ':[a-z]++}', // lower case |
|
| 78 | + ':u}' => ':[A-Z]++}', // upper case |
|
| 79 | + ':a}' => ':[0-9a-zA-Z]++}', // alphanumeric |
|
| 80 | 80 | ':c}' => ':[0-9a-zA-Z+_\-\.]++}', // common chars |
| 81 | - ':nd}' => ':[^0-9/]++}', // not digits |
|
| 82 | - ':xd}' => ':[^0-9/][^/]*+}', // no leading digits |
|
| 81 | + ':nd}' => ':[^0-9/]++}', // not digits |
|
| 82 | + ':xd}' => ':[^0-9/][^/]*+}', // no leading digits |
|
| 83 | 83 | ]; |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -105,17 +105,17 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | // count placeholders |
| 107 | 107 | $map = $m = []; |
| 108 | - if (preg_match_all('~' . $ph . '~x', $pattern, $m)) { |
|
| 108 | + if (preg_match_all('~'.$ph.'~x', $pattern, $m)) { |
|
| 109 | 109 | $map = $m[1]; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | $result = preg_replace( |
| 113 | 113 | [ |
| 114 | - '~' . $ph . '(*SKIP)(*FAIL) | \[~x', '~' . $ph . '(*SKIP)(*FAIL) | \]~x', |
|
| 115 | - '~\{' . self::MATCH_GROUP_NAME . '\}~x', '~' . $ph . '~x', |
|
| 114 | + '~'.$ph.'(*SKIP)(*FAIL) | \[~x', '~'.$ph.'(*SKIP)(*FAIL) | \]~x', |
|
| 115 | + '~\{'.self::MATCH_GROUP_NAME.'\}~x', '~'.$ph.'~x', |
|
| 116 | 116 | ], |
| 117 | - ['(?:', ')?', '{\\1:' . self::MATCH_SEGMENT . '}', '(\\2)'], |
|
| 118 | - strtr('/' . trim($pattern, '/'), $this->shortcuts) |
|
| 117 | + ['(?:', ')?', '{\\1:'.self::MATCH_SEGMENT.'}', '(\\2)'], |
|
| 118 | + strtr('/'.trim($pattern, '/'), $this->shortcuts) |
|
| 119 | 119 | ); |
| 120 | 120 | return [$result, $map]; |
| 121 | 121 | } |
@@ -168,9 +168,9 @@ discard block |
||
| 168 | 168 | $map = $this->getMapData($arr, $this->maps); |
| 169 | 169 | $str = '~^(?|'; |
| 170 | 170 | foreach ($arr as $k => $reg) { |
| 171 | - $str .= $reg . str_repeat('()', $map[$k] - count($this->maps[$k])) . '|'; |
|
| 171 | + $str .= $reg.str_repeat('()', $map[$k] - count($this->maps[$k])).'|'; |
|
| 172 | 172 | } |
| 173 | - $this->data[$i] = substr($str, 0, -1) . ')$~x'; |
|
| 173 | + $this->data[$i] = substr($str, 0, -1).')$~x'; |
|
| 174 | 174 | $this->xmap[$i] = $map; |
| 175 | 175 | } |
| 176 | 176 | $this->modified = FALSE; |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | * @package Phoole\Route |
| 8 | 8 | * @copyright Copyright (c) 2019 Hong Zhang |
| 9 | 9 | */ |
| 10 | -declare(strict_types = 1); |
|
| 10 | +declare(strict_types=1); |
|
| 11 | 11 | |
| 12 | 12 | namespace Phoole\Route\Util; |
| 13 | 13 | |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | * @package Phoole\Route |
| 8 | 8 | * @copyright Copyright (c) 2019 Hong Zhang |
| 9 | 9 | */ |
| 10 | -declare(strict_types = 1); |
|
| 10 | +declare(strict_types=1); |
|
| 11 | 11 | |
| 12 | 12 | namespace Phoole\Route\Util; |
| 13 | 13 | |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | * @package Phoole\Route |
| 8 | 8 | * @copyright Copyright (c) 2019 Hong Zhang |
| 9 | 9 | */ |
| 10 | -declare(strict_types = 1); |
|
| 10 | +declare(strict_types=1); |
|
| 11 | 11 | |
| 12 | 12 | namespace Phoole\Route\Util; |
| 13 | 13 | |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * @package Phoole\Route |
| 8 | 8 | * @copyright Copyright (c) 2019 Hong Zhang |
| 9 | 9 | */ |
| 10 | -declare(strict_types = 1); |
|
| 10 | +declare(strict_types=1); |
|
| 11 | 11 | |
| 12 | 12 | namespace Phoole\Route\Util; |
| 13 | 13 | |
@@ -105,8 +105,7 @@ discard block |
||
| 105 | 105 | public function setMethods($method, $handler, array $defaults): Route |
| 106 | 106 | { |
| 107 | 107 | $methods = is_string($method) ? |
| 108 | - preg_split('~[^A-Z]+~', strtoupper($method), -1, PREG_SPLIT_NO_EMPTY) : |
|
| 109 | - array_map('strtoupper', $method); |
|
| 108 | + preg_split('~[^A-Z]+~', strtoupper($method), -1, PREG_SPLIT_NO_EMPTY) : array_map('strtoupper', $method); |
|
| 110 | 109 | foreach ($methods as $mth) { |
| 111 | 110 | $this->methods[$mth] = [$handler, $defaults]; |
| 112 | 111 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * @package Phoole\Route |
| 8 | 8 | * @copyright Copyright (c) 2019 Hong Zhang |
| 9 | 9 | */ |
| 10 | -declare(strict_types = 1); |
|
| 10 | +declare(strict_types=1); |
|
| 11 | 11 | |
| 12 | 12 | namespace Phoole\Route\Resolver; |
| 13 | 13 | |
@@ -39,13 +39,13 @@ discard block |
||
| 39 | 39 | public function resolve($notCallable): callable |
| 40 | 40 | { |
| 41 | 41 | try { |
| 42 | - $controllerName = $this->namespace . '\\' . $notCallable[0]; |
|
| 42 | + $controllerName = $this->namespace.'\\'.$notCallable[0]; |
|
| 43 | 43 | $methodName = $notCallable[1]; |
| 44 | 44 | $result = [new $controllerName(), $methodName]; |
| 45 | 45 | if (is_callable($result)) { |
| 46 | 46 | return $result; |
| 47 | 47 | } |
| 48 | - throw new \Exception("unable to resolve " . $notCallable[0]); |
|
| 48 | + throw new \Exception("unable to resolve ".$notCallable[0]); |
|
| 49 | 49 | } catch (\Throwable $e) { |
| 50 | 50 | throw new \InvalidArgumentException($e->getMessage()); |
| 51 | 51 | } |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | * @package Phoole\Route |
| 8 | 8 | * @copyright Copyright (c) 2019 Hong Zhang |
| 9 | 9 | */ |
| 10 | -declare(strict_types = 1); |
|
| 10 | +declare(strict_types=1); |
|
| 11 | 11 | |
| 12 | 12 | namespace Phoole\Route\Resolver; |
| 13 | 13 | |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | * @package Phoole\Route |
| 8 | 8 | * @copyright Copyright (c) 2019 Hong Zhang |
| 9 | 9 | */ |
| 10 | -declare(strict_types = 1); |
|
| 10 | +declare(strict_types=1); |
|
| 11 | 11 | |
| 12 | 12 | namespace Phoole\Route; |
| 13 | 13 | |