File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 25
25
* - https://en.wikipedia.org/wiki/Glob_(programming)
26
26
* - https://man7.org/linux/man-pages/man7/glob.7.html
27
27
*
28
+ * The file matcher compiles the regex in three passes:
29
+ *
30
+ * - Tokenise interesting chars in the glob grammar.
31
+ * - Process the tokens and reorient them to produce regex.
32
+ * - Map the processed tokens to regular expression segments.
33
+ *
28
34
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
29
35
*
30
36
* @internal This class is not covered by the backward compatibility promise for PHPUnit
53
59
public static function toRegEx (string $ glob ): FileMatcherRegex
54
60
{
55
61
$ tokens = self ::tokenize ($ glob );
56
- $ regex = '' ;
62
+ $ tokens = self ::processTokens ($ tokens );
63
+
64
+ return self ::mapToRegex ($ tokens );
65
+ }
66
+
67
+ /**
68
+ * @param list<token> $tokens
69
+ */
70
+ public static function mapToRegex (array $ tokens ): FileMatcherRegex
71
+ {
72
+ $ regex = '' ;
57
73
58
74
foreach ($ tokens as $ token ) {
59
75
$ type = $ token [0 ];
@@ -111,7 +127,7 @@ private static function tokenize(string $glob): array
111
127
};
112
128
}
113
129
114
- return self :: processTokens ( $ tokens) ;
130
+ return $ tokens ;
115
131
}
116
132
117
133
/**
You can’t perform that action at this time.
0 commit comments