getBasePath() returns incorrect value for bare stream wrapper path #65
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've run into a bug where trying to glob a stream path on just the root fails. Specifically, in my app,
Glob::getBasePath('foo://');
returnsfoo:/
, rather thanfoo://
. That means when trying toGlob::glob('foo://*')
, the base path is wrong, so it cannot find any files. Moreover, since PHP doesn't recognizefoo:/
as a file stream, whatever stream wrapper is registered forfoo
gets ignored. (Specifically, theelseif (is_dir($basePath))
clause comes backfalse
, because there's no stream wrapper forfoo:/
, only forfoo://
.)I believe the attached PR fixes the issue, though I defer to the maintainers if they'd prefer to take a slightly different approach. I had to split the test cases up because presumably a path of
''
is not supposed to be supported as it's not absolute.I... do not understand why the tests are failing with a permission denied error on PHP 8.0 only. That feels spurious, but perhaps the maintainers have a better understanding of what gives.