Conditions | 2 |
Paths | 2 |
Total Lines | 14 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
15 | public function match(Request $request, Element $config) |
||
16 | { |
||
17 | $pathPattern = $config->getRequest()->getPath(); |
||
18 | preg_match_all('#\{\w+\}#', $config->getRequest()->getPath(), $placeholders, PREG_OFFSET_CAPTURE | PREG_SET_ORDER); |
||
19 | |||
20 | foreach ($placeholders as $placeholderMatch) { |
||
|
|||
21 | $placeholder = $placeholderMatch[0][0]; |
||
22 | $pathPattern = str_replace($placeholder, '__PLACEHOLDER__', $pathPattern); |
||
23 | } |
||
24 | |||
25 | $pathPattern = '/^' . str_replace('__PLACEHOLDER__', '([^\/]*)', preg_quote($pathPattern, '/')) . '$/i'; |
||
26 | |||
27 | return 0 !== preg_match($pathPattern, $request->getPathInfo()); |
||
28 | } |
||
29 | } |
||
30 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.