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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swissspidy This now saves against the thrown notice, but I'm wondering whether it doesn't now exclude valid matches.
If
$base
is empty, should a match be possible here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old code, without my change, in context, was:
Written another way:
My change only suppresses the warning:
My change doesn't change how the code works, it only suppresses the PHP Warning.
If a match is possible, and the testing suite doesn't catch it, then that's beyond the scope of my PR IMHO.
Hope this helps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it was clear how the logic works. However, the PR should ideally be about eliminating the root cause of a bug, not just obfuscating it.
In this case, the root cause is that one possible scenario was apparently not being considered by the current logic. The notice as such is valuable as it shows us we apparently forgot something. If we now just hide the notice, the possible bug might still be in there and forgotten because the symptom is being hidden.
This is why I'd like some feedback by @swissspidy, who built the original code, as I'm unsure what an empty base in this case would signify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I think my initial work was pretty much rewritten in #104. So maybe @herregroen knows more?
The warning implies that
$path_or_file
is an empty string and I wonder why this happens. If it's because of some edge case thing I don't think justbreak
ing early would cause any troubles.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this helps? I can reproduce every time by running:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swissspidy I think you misread the code. The issue is not that
$path_or_file
is empty, but thatcurrent( explode( '*', $path_or_file ) )
returns an empty string. This happens for a simple example like*.php
, as it will explode to[ '', '.php' ]
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, indeed! My bad.