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 2525 * - https://en.wikipedia.org/wiki/Glob_(programming)
2626 * - https://man7.org/linux/man-pages/man7/glob.7.html
2727 *
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+ *
2834 * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
2935 *
3036 * @internal This class is not covered by the backward compatibility promise for PHPUnit
5359 public static function toRegEx (string $ glob ): FileMatcherRegex
5460 {
5561 $ 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 = '' ;
5773
5874 foreach ($ tokens as $ token ) {
5975 $ type = $ token [0 ];
@@ -111,7 +127,7 @@ private static function tokenize(string $glob): array
111127 };
112128 }
113129
114- return self :: processTokens ( $ tokens) ;
130+ return $ tokens ;
115131 }
116132
117133 /**
You can’t perform that action at this time.
0 commit comments