1 | <?php /** MicroRouter */ |
||
19 | class Router implements IRouter |
||
20 | { |
||
21 | /** @var array $routes routes for routing */ |
||
22 | public $routes = []; |
||
23 | |||
24 | |||
25 | /** |
||
26 | * Construct for route scanner |
||
27 | * |
||
28 | * @access public |
||
29 | * |
||
30 | * @param array $config |
||
31 | * |
||
32 | * @result void |
||
33 | */ |
||
34 | public function __construct(array $config = []) |
||
38 | |||
39 | /** |
||
40 | * @inheritdoc |
||
41 | */ |
||
42 | public function parse($uri, $method = 'GET') |
||
75 | |||
76 | /** |
||
77 | * Validated router rule |
||
78 | * |
||
79 | * @access private |
||
80 | * |
||
81 | * @param string $uri uri to validation |
||
82 | * @param string $pattern checking pattern |
||
83 | * @param string $replacement replacement for pattern |
||
84 | * |
||
85 | * @return string |
||
86 | */ |
||
87 | private function validatedRule($uri, $pattern, $replacement) |
||
120 | |||
121 | /** |
||
122 | * Match patBlocks in uriBlocks |
||
123 | * |
||
124 | * @access private |
||
125 | * |
||
126 | * @param array $uriBlocks uri blocks from URL |
||
127 | * @param array $patBlocks pattern blocks from valid URL |
||
128 | * |
||
129 | * @return array|bool |
||
130 | */ |
||
131 | private function parseUri(array $uriBlocks = [], array $patBlocks = []) |
||
154 | |||
155 | /** |
||
156 | * Replacement $result with repBlocks |
||
157 | * |
||
158 | * @access private |
||
159 | * |
||
160 | * @param array $attr elements of valid URL |
||
161 | * @param array $repBlocks replacement blocks from valid URL |
||
162 | * |
||
163 | * @return bool|null|string |
||
164 | */ |
||
165 | private function buildResult(&$attr, $repBlocks) |
||
189 | } |
||
190 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.