Sean Sean - 4 years ago 237
PHP Question

How do I make phpcs ignore some files in PHP Storm?

I've set up PHP Storm to use phpcs and show me in the IDE when I've violated a style.

However, I'd like to disable this for view files -- they often contain bits of PHP mixed with HTML that don't match the style guide, and I don't care in a view file.

In the options, I see a list of excluded files in the phpcs settings, but it only has buttons to remove a file or clear the whole list, but no way to ADD files to it.

Am I missing it somewhere?

Answer Source

Code Sniffer (as well as Mess Detector) integration is implemented in form of an Inspection which can be configured to be ON or OFF based on scope. Therefore:

  1. Settings | Scopes -- create new custom scope and include all unwanted files/folders

  2. Settings | Inspections | PHP | PHP Code Sniffer validation -- right click on it and choose Add Scope

  3. Now configure this inspection: turn OFF (uncheck) for that scope and leave ON for "Everywhere else" entry.

P.S. PhpStorm v8 has Inspections settings screen a bit redesigned; therefore steps are tiny bit different, but still the same overall (now it's easier for user to discover "scopes" functionality).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download