phpstormphp-cs-fixer

Exclude directories from PHP CS Fixer analisys in PhpStorm


I have multiple sub-projects inside a main project, and just one works fine with PHP CS Fixer.

Is it possible to exclude certain directories from PHP CS Fixer in PhpStorm 2023.1.2?


Solution

  • PHP CS Fixer (as well as other Code Quality tools), they report the results back to the IDE using the Inspections mechanics. Since it's an inspection, it means that you can use scopes...

    From https://www.jetbrains.com/help/phpstorm/code-inspection.html

    Inspections can scan your code in all project files or only in specific scopes (for example, only in production code or in modified files).

    So what you can do is:

    1. Create a custom Scope that will include only desired folders/files.
    2. Add that scope in the corresponding inspection: enable it for that scope and disable for Everything else.

    enter image description here

    (The image is taken from a similar ticket. It's not exactly what I'm talking here but very close and gives clear idea on how it should be done)