1 | <?php |
||
5 | class RegEx |
||
6 | { |
||
7 | const REGEX_CHARS_REPLACEMENT = [ |
||
8 | " " => '\s', |
||
9 | "\t" => '\t', |
||
10 | "\n" => '\n', |
||
11 | "\f" => '\f', |
||
12 | "\r" => '\r', |
||
13 | "\v" => '\v', |
||
14 | // "\h" => '\h', |
||
|
|||
15 | // "\R" => '\R', |
||
16 | ]; |
||
17 | |||
18 | /** |
||
19 | * Validate if RegEx statement is valid |
||
20 | * |
||
21 | * @param string $regexStatement |
||
22 | * |
||
23 | * @return bool |
||
24 | */ |
||
25 | public static function isValid(string $regexStatement) : bool |
||
29 | |||
30 | /** |
||
31 | * Prepare string to be safety used in regex |
||
32 | * |
||
33 | * @param string $string |
||
34 | * @param string $quotes |
||
35 | * |
||
36 | * @return string |
||
37 | */ |
||
38 | public static function prepare(string $string, $quotes = '/') : string |
||
48 | } |
||
49 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.