Closed sunnyingit closed 9 years ago
Any more detail you can provide?
@aik099, I can confirm that the PSR1.Classes.ClassDeclaration
sniff cannot be excluded by using the command line --sniffs
attribute. However, it can be achieved by using a ruleset override this way.
<rule ref="PSR1">
<exclude name="PSR1.Classes.ClassDeclaration"/>
</rule>
However, if I don't want to exclude it entirely, it doesn't seem that I can easily lower its severity so it won't get reported. Below ruleset override doesn't take effect.
<rule ref="PSR1.Classes.ClassDeclaration">
<severity>0</severity>
</rule>
The report still prints this error. Is there anymore specific details you need to get the investigation started?
Thanks.
You can't exclude sniffs on the command line. You can only limit the checking to specific sniffs.
And you can't change the severity of an entire sniff. You can only change the severity of individual messages within it (these are 4-part codes instead of the 3-part sniff codes).
Ahh, thanks. No wonder I can get this to work.
<rule ref="Squiz.Classes.ValidClassName.NotCamelCaps">
<severity>4</severity>
</rule>
vendor/bin/phpcs --standard=PSR2 --sniffs=PSR1.Classes.ClassDeclaration --extensions=php app/models/Weixin.php
the report result is 3 | ERROR | Each class must be in a namespace of at least one level | | (a top-level vendor name)