0

I have a project in PhpStorm 2019.2.3 for which I want to use a custom coding standard ruleset with PHP Code Sniffer. The Code Sniffer works as expected, when I choose a provided coding standard, but when I change to my custom ruleset, all sniffs disappear.

I copied the whole /PSR2 folder under /PHP_CodeSniffer-3.4.2/src/Standards/, named it PSR2-Custom and edited the contained ruleset.xml to this:

<?xml version="1.0"?>
<ruleset name="PSR2R">
    <rule ref="PSR2">
    <exclude name="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine" />
        <exclude name="PSR2.Classes.ClassDeclaration.OpenBraceNewLine" />
    </rule>
    <rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie" />
</ruleset>

What I think it does is that it uses the PSR2 coding standard and excludes two of the contained rules, inspired by phpcs: How can I modify PSR2 to check that the brace is on the same line as the method? and https://github.com/squizlabs/PHP_CodeSniffer/issues/703

These are my settings:

A) Settings > Languages & Frameworks > PHP > Quality Tools:

local configuration with path to phpcs.bat (PHP_CodeSniffer-3.4.2, manually downloaded) (as documented)

B) Settings > Editor > Inspections: PHP > Quality tools > PHP Code Sniffer Validation:

-> choosing PSR2 in 'Coding standards' dropdown: sniffs marked
-> choosing PSR2-Custom in 'Coding standards' dropdown: no sniffs marked anymore

I checked similar issues on SO, but non of them helped me with my problem, e.g. Custom PMD ruleset not working

I can't figure out, where I went wrong. Is my ruleset config buggy? Thanks for helping out.

jasie
  • 2,192
  • 10
  • 39
  • 54

0 Answers0