-
-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support to resolve globstar when creating FileIterator #82
Labels
Comments
nicDamours
pushed a commit
to nicDamours/php-file-iterator
that referenced
this issue
Aug 13, 2024
Added support for globstar when resolving paths in the FileIterator factory. The extended glob function was adapted from funkjedi's implementation: https://gist.github.com/funkjedi/3feee27d873ae2297b8e2370a7082aad Fixed facade test to include newly created fixture directories.
nicDamours
pushed a commit
to nicDamours/php-file-iterator
that referenced
this issue
Aug 13, 2024
Removed unnecessary formatting changes.
nicDamours
pushed a commit
to nicDamours/php-file-iterator
that referenced
this issue
Aug 14, 2024
Fixed static code analysis errors.
nicDamours
pushed a commit
to nicDamours/php-file-iterator
that referenced
this issue
Aug 14, 2024
Added check to make sure $files isn't false when sorting the array. Otherwise, we return an empty array.
nicDamours
pushed a commit
to nicDamours/php-file-iterator
that referenced
this issue
Aug 15, 2024
Ignore coverage for the last line of the globstar function, since it's only used if the glob function returns an error. Added a test to validate the behaviour of the globstar function when passing non existant glob pattern. Fixed code using php-cs-fixer. Fixed error reported by phpstan.
What a coincidence that I had the same problem today ^^ |
sebastianbergmann
pushed a commit
that referenced
this issue
Aug 27, 2024
Added support for globstar when resolving paths in the FileIterator factory. The extended glob function was adapted from funkjedi's implementation: https://gist.github.com/funkjedi/3feee27d873ae2297b8e2370a7082aad Fixed facade test to include newly created fixture directories.
sebastianbergmann
pushed a commit
that referenced
this issue
Aug 27, 2024
sebastianbergmann
pushed a commit
that referenced
this issue
Aug 27, 2024
sebastianbergmann
pushed a commit
that referenced
this issue
Aug 27, 2024
sebastianbergmann
pushed a commit
that referenced
this issue
Aug 27, 2024
Ignore coverage for the last line of the globstar function, since it's only used if the glob function returns an error. Added a test to validate the behaviour of the globstar function when passing non existant glob pattern. Fixed code using php-cs-fixer. Fixed error reported by phpstan.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Summary
Currently, glob are supported, but only using the default
glob
php function, which is quite limited. The default glob function doesn't allow for the usage of "globstar", which is a pretty common practice when targeting files using glob patterns.Problem
Without globstar, we are limited to a single level of "unspecified" directory, when using filter in libraries such as phpunit. Take the following structure as example.
Using the current implementation of the
Factory::resolveWildcards
function, we can use the following pattern to target the directorytarget_directory
right underdirectory_1
:However, it is not possible to target the
target_directory
underdirectory_2_2_1
, since the glob pattern is only looking at the first level. It basically translates toroot_directory/{any directory}/target_directory
.This means we need to pass multiple patterns to the filter in order to target all
target_directory
.This solution is problematic when the directory structure changes a lot, which is pretty common when building complex projects.
Solution.
There are a few solutions, online, to extend the
glob
function behaviour to include globstar. One such solution can be found here..I tried to implements this particular solution and it seams to be working fine in my local environment.
I will try to submit a PR that could fix the issue.
The text was updated successfully, but these errors were encountered: