1

phpcs is installed on the system and code sniffing works fine from the command line.

phpcs --extensions=php /path/to/code.php` 

^ works fine.

For the PHP Storm IDE, I've specified the location of the ruleset.xml file in the settings like so:

Cmd + , > PHP Code Sniffer validation > Coding standard > Custom > Path to ruleset.xml

However, I get this error:

PHP Code Sniffer
        phpcs: /Users/gketkar/code-sniffer/Blah/ruleset.xml: line 1: syntax error near unexpected token `newline'
        /Users/gketkar/code-sniffer/Blah/ruleset.xml: line 1: `<?xml version="1.0"?>'

UPDATE: The ruleset.xml file looks like this:

<?xml version="1.0"?>
<ruleset name="Blah">
    <description>Blah Coding Standards</description>
    <rule ref="Generic">
        <exclude name="Generic.Formatting.SpaceAfterCast.NoSpace"/>
        <exclude name="Generic.PHP.DeprecatedFunctions"/>
        <exclude name="Generic.PHP.DisallowShortOpenTag.EchoFound"/>
        <exclude name="Generic.PHP.UpperCaseConstant.Found"/>
    </rule>
</ruleset>
Ketcomp
  • 434
  • 6
  • 20

1 Answers1

0

This looks like you have the ruleset.xml loaded into the setting that should have the phpcs binary. In PHPStorm:

  1. Open preferences
  2. Navigate to Language & Frameworks > PHP > Code Sniffer
  3. Click the [...] next to the configuration
  4. Validate the path to the phpcs

Make sure that path points to a phpcs file and not the ruleset.xml file. If you don't have one, try https://packagist.org/packages/squizlabs/php_codesniffer

KeyboardCowboy
  • 563
  • 4
  • 13