| Conditions | 2 |
| Paths | 2 |
| Total Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 38 | private function parse($txtProperties) |
||
| 39 | { |
||
| 40 | $result = []; |
||
| 41 | |||
| 42 | // first remove all escaped whitespace characters: |
||
| 43 | $txtProperties = preg_replace('/(?<!\\\\)\\\\[\r\n\t\f\v][ \r]*/', '', $txtProperties); |
||
| 44 | |||
| 45 | // next split all lines not starting with # or ! on characters = or : (unless escaped): |
||
| 46 | preg_match_all('/^([^#!].*)(?<!\\\\)[=:](.*)$/mU', $txtProperties, $matches, PREG_SET_ORDER, 0); |
||
| 47 | |||
| 48 | foreach ($matches as $match) { |
||
|
|
|||
| 49 | $result[trim(stripslashes($match[1]))] = trim(stripslashes($match[2])); |
||
| 50 | } |
||
| 51 | |||
| 52 | return $result; |
||
| 53 | } |
||
| 54 | |||
| 63 |
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.