| @@ -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 | /** | 
| @@ -104,16 +104,16 @@ discard block | ||
| 104 | 104 |          $ph = sprintf("\{%s(?:%s)?\}", self::MATCH_GROUP_NAME, self::MATCH_GROUP_TYPE); | 
| 105 | 105 | // count placeholders | 
| 106 | 106 | $map = $m = []; | 
| 107 | -        if (preg_match_all('~' . $ph . '~x', $pattern, $m)) { | |
| 107 | +        if (preg_match_all('~'.$ph.'~x', $pattern, $m)) { | |
| 108 | 108 | $map = $m[1]; | 
| 109 | 109 | } | 
| 110 | 110 | $result = preg_replace( | 
| 111 | 111 | [ | 
| 112 | - '~' . $ph . '(*SKIP)(*FAIL) | \[~x', '~' . $ph . '(*SKIP)(*FAIL) | \]~x', | |
| 113 | -                '~\{' . self::MATCH_GROUP_NAME . '\}~x', '~' . $ph . '~x', | |
| 112 | + '~'.$ph.'(*SKIP)(*FAIL) | \[~x', '~'.$ph.'(*SKIP)(*FAIL) | \]~x', | |
| 113 | +                '~\{'.self::MATCH_GROUP_NAME.'\}~x', '~'.$ph.'~x', | |
| 114 | 114 | ], | 
| 115 | -            ['(?:', ')?', '{\\1:' . self::MATCH_SEGMENT . '}', '(\\2)'], | |
| 116 | -            strtr('/' . trim($pattern, '/'), $this->shortcuts) | |
| 115 | +            ['(?:', ')?', '{\\1:'.self::MATCH_SEGMENT.'}', '(\\2)'], | |
| 116 | +            strtr('/'.trim($pattern, '/'), $this->shortcuts) | |
| 117 | 117 | ); | 
| 118 | 118 | return [$result, $map]; | 
| 119 | 119 | } | 
| @@ -165,9 +165,9 @@ discard block | ||
| 165 | 165 | $map = $this->getMapData($arr, $this->maps); | 
| 166 | 166 | $str = '~^(?|'; | 
| 167 | 167 |              foreach ($arr as $k => $reg) { | 
| 168 | -                $str .= $reg . str_repeat('()', $map[$k] - count($this->maps[$k])) . '|'; | |
| 168 | +                $str .= $reg.str_repeat('()', $map[$k] - count($this->maps[$k])).'|'; | |
| 169 | 169 | } | 
| 170 | - $this->data[$i] = substr($str, 0, -1) . ')$~x'; | |
| 170 | + $this->data[$i] = substr($str, 0, -1).')$~x'; | |
| 171 | 171 | $this->xmap[$i] = $map; | 
| 172 | 172 | } | 
| 173 | 173 | $this->modified = FALSE; | 
| @@ -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) | 
| 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 | } |