-
Notifications
You must be signed in to change notification settings - Fork 23
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
Do not pass &$parts as reference to resolvePharParentPath #67
Closed
+10
−2
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
I looked at this method and the logic does not make sense to me. The purpose of it was to remove current and previous segment in a path, where current segment was
...
? Is triple-dots even ever used in phar paths? Moreover this method would be buggy if...
was at the beginning of a path.If the original intention was to have
..
there instead of...
then it would maybe make more sense... but the logic here to mutate$parts
array passed by reference looks awkward and is forbidden in php8 while usingarray_walk
. The change that$parts
is no longer a reference is even worse now, because the method would basically do nothing in result in all cases incl....
value.It looks like a workaround for a super-rare edge case to me. The case with
...
is also not tested. We could try to refactor it in a loop or something, but I think I'd get rid of this method completely.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.
@falkenhawk but ths pr did not modify line including
if ($value !== '...') {
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 removed reference from
$parts
which made the method obsolete, but I tried to figure out the original purpose of the method...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.
Just noticed this #74 - it actually addresses the same issue.
But, I still wonder, why there is a condition for
...
insideresolvePharParentPath
- it just looks off to me.Btw, when I change that to
..
in #74 to actually allow the$parts
array to be modified in tests, ...it crashes in tests for me locally on php 7.3 (win) with a weird error.Per https://www.php.net/manual/en/function.array-walk.php :
The logic here is definitely not very safe 🙈
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.
I've moved everything but this change to separate PRs, so they won't suffer the delay by code review.