Search code examples
phpcomposer-phpphpstormphpstorm2017.3

Suppress error messages / inspections for for specific folders or files


I'm using Composer and I don't want PhpStorm to run any error checking or inspections on the vendor folder as it is showing a false positive for some code in the vendor/composer/autoload_static.php file and hence is highlighting the lines in the file, the file itself on the left pane and it's parent folders as well all with a red underline and it's distracting.

According to this question, which is basically the issue I am having, PhpStorm isn't currently smart enough to realize this isn't actually an error.

Here is the issue from the actual file:

enter image description here

I have been trying to work out how to get PhpStorm how to ignore these folders or file and I can't seem to figure it out!?

I have tried clicking on the "little guy with the hat" at the bottom right and changing the inspection levels but it doesn't seem to make any difference.

How can I get PhpStorm to ignore these folders and get rid of the annoying red lines?

I'm using PhpStorm 2017.3


Solution

  • Issues of "Error" severity should NOT be shown in Project View panel for 3rd party code (e.g. Composer packages). The fact that they are showing -- packages are not managed in ideal way by IDE (see below) or project is not fully indexed yet.

    In general: if you have Settings/Preferences | Languages & Frameworks | PHP | Composer --> Add packages as libraries option enabled, IDE will mark all your composer packages folders as excluded (Settings/Preferences | Directories) .. and then re-add them back as individual Include paths (Settings/Preferences | Languages & Frameworks | PHP) -- that's when you may see a library root text next to them. This is enough for IDE to stop showing errors for such files in Project View panel (as such files are no longer treated as part of the project code / not your code).

    P.S. Even if you still see that red underwave in Project View panel .. it will disappear when you re-open the project (and will not open that file again).


    The actual issue with the error highlighting: most likely will be this one: https://youtrack.jetbrains.com/issue/WI-29871 (Closure::bind).


    In case if you still want to get rid of those "errors" even in the file itself: just right click it (in Project View) and chose Mark as Plain Text -- this file will no longer be treated as PHP so no syntax checks.

    You could also use custom Scope (that will include such unwanted files) and disable particular inspection(s) for that scope in Settings/Preferences | Editor | Inspections .. but it will not work for already excluded files (as Scopes work with project files only). This can be used in other cases though where you want to have file/folder-wide inspection suppression.