-
-
Notifications
You must be signed in to change notification settings - Fork 288
Fix path resolver when path start with directory separator #509
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
Conversation
3969bd7
to
7e84090
Compare
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.
Hey @50bhan, just tested your implementation.
Given PHPInsights is installed globally, I execute it from my HOME directory.
$ phpinsights analyse /tmp/app
This work and launch the analyse on the expected directory
$ phpinsights analyse /tmp
This doesn't work, raise the following exception :
The "/home/barth/tmp" directory does not exist.
So we have a regression here
public function testResolvePathWithDirectorySeparator(): void | ||
{ | ||
$path = '/app'; | ||
$sanitizedPath = getcwd() . $path; |
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 think it's incorrect.
If I provide an absolute path (like /app
), this shouldn't be resolved as current working dir + app
.
@50bhan, for me, the bug is here https://github.com/nunomaduro/phpinsights/blob/master/src/Infrastructure/Repositories/LocalFilesRepository.php#L66 Could be resolved like this $this->directoryList[] = rtrim($pathInfo['dirname'], DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $pathInfo['basename']; But I'm not sure it'll work on Windows. |
Actually, this isn't the correct workaround. At first, I did the exact change that you've made. But the problem still remains: |
@50bhan i think it's the expected behaviour. When we pass an absolute path, it should be used. But in the LocalFileRepository, it transform |
@Jibbarth I was confused about it. If this is the case, the fix is easy as you said. I'll update the PR. |
Great ! If I found a Windows, I'll test against |
7e84090
to
c82cc16
Compare
@Jibbarth Thanks, it would be awesome. I updated the PR. Edit: Needed to upgrade Rector to avoid CI failure. |
9e11b9c
to
6f5225f
Compare
6f5225f
to
2abfb75
Compare
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.
Tested on Windows, bug was also present and now it's fixed 🎉
Thank you @50bhan 🙏
This PR will close #508.