Closed alleknalle closed 6 months ago
Hi, Thanks for sharing your use case here. I think that it will be a great addition to the project!
A filename-based filter method could be added to all the iterators (and finders), allowing to use them in codebases with different code styles.
Feel free to open a PR with your additions. We could try to generalise them after.
Hi there!
I'm currently working on some WordPress plugins/themes and I'm using this library to easily require and find certain classes. I was using
ComposerFinder
, but since I don't always use Composer (for my themes), I switched toRecursiveFinder
. When using this I noticed that it was requiring some 'non-class' files as well, causing some output. Since WordPress has their own coding standards, this can be easily fixed by only requiring files that start withclass
. First I tried to fix this by usingfilter
on theFinder
, but when the filter is called, the files are already included. So I checked where the files are included and that is inRecursiveIterator
. Since there was no way to filter files here (except for creating a PR), I created my ownClassIterator
(andFinder
to make sure my own iterator was called) where I check if the file starts withclass
. This works perfectly and I thought it would be nice to add this to the package as well. I will try to create a PR somewhere soon, this issue is more so you can maybe think of this as well and as a reminder to myself ;-)