Skip to content

Conversation

dotdash
Copy link

@dotdash dotdash commented Dec 5, 2024

For each root namespace, the slevomat rule considers the left-most match of the given directory in the absolute path of the file. That is, for /home/user/src/phpstan-src/ the root namespace PHPStan is not assigned to /home/user/src/phpstan-src/src, but to /home/user/src, which is obviously wrong.

The bug is known as slevomat/coding-standard#1249 for a long time, but yet to be fixed. To avoid issues for developers of PHPStan, we can set a basepath of "." in the PHP CodeSniffer config, which causes paths to be evaluated relative to the current directory, avoiding false-positives in the path leading up to the phpstan-src directory.

For each root namespace, the slevomat rule considers the left-most
match of the given directory in the absolute path of the file. That is,
for /home/user/src/phpstan-src/ the root namespace PHPStan is not
assigned to /home/user/src/phpstan-src/src, but to /home/user/src, which
is obviously wrong.

The bug is known as slevomat/coding-standard#1249 for a long time, but
yet to be fixed. To avoid issues for developers of PHPStan, we can set
a basepath of "." in the PHP CodeSniffer config, which causes paths to
be evaluated relative to the current directory, avoiding
false-positives in the path leading up to the phpstan-src directory.
@dotdash dotdash changed the base branch from 2.0.x to 1.11.x December 5, 2024 11:23
@ondrejmirtes ondrejmirtes merged commit 0464ac1 into phpstan:1.11.x Dec 5, 2024
267 checks passed
@ondrejmirtes
Copy link
Member

Had to revert it because you based it on a really old branch. I cherry-picked it into 2.0.x again.

@dotdash
Copy link
Author

dotdash commented Dec 5, 2024

Oh, I'm sorry, I had meant to put it to 1.12.x but must have typo'ed that as 1.11.x and then proceeded to choose that as the base here as well 🤦🏻

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.

3 participants