-
-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
TypeNameMatchesFileName Namespace calculation is broken if having double source dir (src/src) #1249
Comments
@c33s |
@kukulich i am not sure if that would make sense. only because i put the project in another |
my current workaround is to patch add to your composer.json
put into
|
@kukulich can you please merge #987 edit:
hardcoding my local path would make no sense as the path would only be valid for my computer and will result in a broken pipeline as the path would be different in this case. may i ask what is the problem of merging the bugfix? apparently there is a bug and the workaround (hardcoding |
ping |
I have a similar issue when checking the coding standards in https://github.com/phpstan/phpstan-doctrine which uses such config: <rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
<properties>
<property name="rootNamespaces" type="array">
<element key="src" value="PHPStan"/>
<element key="tests" value="PHPStan"/>
</property>
</properties>
</rule> when cloning that repo in
To me, it looks like it tries to match the |
Yeah, same here with PHPStan:
Moving it to |
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.
FWIW, for PHPStan setting the |
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.
the MR #987 which would fix exactly this problem was not merged. i have exactly the problem described in this MR, if you structrue you code in an additional
src
dir the namespace calculation is brokenpath:
/projects/entity-loader-bundle
where i use the additional level to have for e.g. an additional tmp dir or for cloning two branches of my bundle at the same time, or for cloning the gitlab wiki repo, the namespace detection is broken.
my path is
where the config files resides in
having this config (exactly like in the composer autoload section)
i get (
\SlevomatCodingStandard\Sniffs\Files\TypeNameMatchesFileNameSniff
):The text was updated successfully, but these errors were encountered: