Skip to content

Commit

Permalink
Workaround bug in slevomat/coding-standard TypeNameMatchesFileName
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DemvSteinbrink committed Dec 5, 2024
1 parent 4f33a8e commit 7057fca
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<ruleset name="PHPStan">
<config name="php_version" value="70400"/>
<arg name="basepath" value="."/>
<arg name="colors"/>
<arg name="extensions" value="php"/>
<arg name="encoding" value="utf-8"/>
Expand Down

0 comments on commit 7057fca

Please sign in to comment.