Skip to content

Fix SimpleRelativePathHelper stripping first character when working directory is slash - #6646

Open
liamduckett wants to merge 3 commits into
phpstan:2.3.xfrom
liamduckett:3579
Open

liamduckett wants to merge 3 commits into
phpstan:2.3.xfrom
liamduckett:3579

Conversation

@liamduckett

Copy link
Copy Markdown

Hey, fixes #3579.

My understanding of the problem, is that this code was written to deal with working directories without a leading slash. This is the case almost all of the time, as the working directory is normalized to remove such. The one exception is when working from the root directory (/) as removing the leading slash would result in an empty string (which has different semantic meaning).

There is another instance of this bug in SystemAgnosticSimpleRelativePathHelper however I have left it our of this PR as it’s usage looks a little more involved (which would make it harder for me to write tests for). Happy to investigate if desired?

Does not attempt to fix the “CWD partial match” described in #52 (comment) as this feels like a separate issue. Happy to pick up here if desired?

Relates to:

@liamduckett

Copy link
Copy Markdown
Author

Failures look unrelated?

@staabm

staabm commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

github reports this branch is 2284 commits behind the PR target-branch

Comment thread tests/PHPStan/File/SimpleRelativePathHelperTest.php
Comment thread tests/PHPStan/File/SimpleRelativePathHelperTest.php
@liamduckett

Copy link
Copy Markdown
Author

github reports this branch is 2284 commits behind the PR target-branch

My bad, looks like my fork was still tracking 2.1.x... should be resolved now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

checkstyle error formatter cuts the path to file when remote interpreter used for the run

2 participants