Ref T5105. This function is an improved version of fnmatch. Internally, this function converts a glob pattern into a regular expression and is based on Symfony\Component\Finder\Glob, with influence from editorconfig-core-js.
The PHP fnmatch() is inadequate for our use case for a variety of reasons:
- Lack of error handling (fnmatch('{', '') does not throw an exception).
- Lack of support for {} groupings (fnmatch('{a,b}', 'a') returns false).
- **/* only matches in subdirectories (fnmatch('**/file', $x) matches $x = 'subdir/file' but does not match $x = 'file').