[php-src] Issue #7730: RecursiveRegexIterator
| From: | noreply@php.net | Date: | Tue, 07 Dec 2021 12:58:10 +0000 |
| Subject: | [php-src] Issue #7730: RecursiveRegexIterator | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-238258@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/7730
Comment Author: iluuu1994
@WinterSilence So the way it works is the regex is applied in each iteration to each directory
before it is eventually applied to the file.
```
- foo
- foo.php
- bar
- bar.php
```
The iterator will first filter directories
foo and bar by
\.php$ which will already exclude both of them. You could do something like
(/\.)|(\.php)$ to allow any directory but that means all directories will be in your
result set and you'll once again have to filter them out.
I suggest using [this](https://github.com/php/php-src/issues/7730#issuecomment-987849203) approach.
RecursiveRegexIterator probably works as expected, although its usefulness is
questionable. [There are only 21
usages](https://grep.app/search?q=new%20%28%5C%5C%3F%29RecursiveRegexIterator®exp=true) of
this class on GitHub.