83

I have a project in PHPStorm, which contains a few libraries (Zend, Doctrine, ...) grouped under a library folder.

When running the code inspection, I do want the PHP code in these folders to be analysed (so that PHPStorm will know how Zend_Form is declared, for example).

However, I do not want the issues found in these folders to be reported, as they are out of my control.

The only workaround I've found so far is to mark the directories as "Test source", and uncheck the "Include test sources" box in the code inspection window. Needless to say that this is not the best solution!

BenMorel
  • 34,448
  • 50
  • 182
  • 322

5 Answers5

118

If you just need to disable inspections on one or two files, you can disable it at the file level easily:

  1. Open offending file
  2. Click 'Code' -> 'Configure Current File Analysis'
  3. Set slider for offending language to 'None'

(Using PHPStorm 8.0.2)

Justin
  • 26,443
  • 16
  • 111
  • 128
  • 7
    This did the trick for me. The menu item was `Code > Configure Current File Analysis` or `command-shift-option-h` – Andy Fleming May 17 '15 at 19:22
  • That is amazing! I was working on a mammoth HTML file that had no business being checked or whatever and it was destroying PHPStorm. – Alper Jan 22 '16 at 15:04
  • this works for WebStorm too but the option is called 'Configure Current File Analysis" from the Code menu – Sul Aga Apr 02 '16 at 20:51
  • 2
    for the menu use: control + shift + alt + h for windows – D. J. Mar 26 '19 at 09:57
  • Step #2 is not possible "Click 'Code' -> 'Configure Current File Analysis'", that doesn't exist in my version of phpStorm 2022.3 D. J. instructions did work. Press: Control + Shift + Alt + H on Windows PC – ChrisDeDavidMindflowAU Jan 03 '23 at 19:09
65

Please refer to the Scopes feature. You can define a custom scope for just your code, without the library folder, then run inspections on this scope only.

In the Inspections settings it's also possible to add the scopes and enable/disable each inspection per scope.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
  • 18
    Wishing you had specified some examples of patterns; it took me a long time to figure out what I needed. Since I figured it out I'll provide here for the benefit of the next person who comes looking: https://gist.github.com/mikeschinkel/5529171 – MikeSchinkel May 06 '13 at 23:38
  • 4
    WebStorm/PhpStorm is great -- but this is **still** one of the most frustrating issues for me. It should be way easier to exclude inspection for vendor libraries. – null Sep 05 '13 at 08:12
  • 7
    @null no doubt. Should be able to right click a folder and say "settings" => "exclude from inspections" My system has the CPU pinned when i try to exclude a few 1000 folders at once via the scopes dialog (Meteorjs application) – Mike Graf Oct 11 '13 at 19:20
  • The scope feature is still one of the most confusing options. It is so powerful that a simple *"please ignore these 3 files from now on and with everything else do exactly as you did before"* needs way to much reading, understanding and testing. I don't want to alter the entire code inspection I just want to add "some" exclusions. For now I'm using [this answer](http://stackoverflow.com/a/17168794/601386) as a simpler workaround. – flu Oct 28 '13 at 09:57
  • 2
    I've created a scope for my project files, but how i can tell IDE not to inspect all other files? When i hit "add scope" in the Inspections section, it creates an enormously giant tree of all possible inspectors and adds two checkboxes for every leaf: "My project", "everything else". How can i untick all checkboxes for "everything else" and leave ticked only "My project"? – Slava Fomin II Nov 27 '13 at 08:33
  • To avoid having to deselect each option individually: Export your inspection profile to some directory. Open the exported XML file in your text editor of choice and replace `enabled_by_default="true"` with `enabled_by_default="false"`. Save, then import the file. – Eric Apr 10 '14 at 20:23
  • It sure would be awesome if there was an option for a "git scope" that automatically hid (and stayed in sync) with files excluded by .gitignore – Subfuzion Aug 29 '14 at 04:17
16

If you need to completely exclude few files from any analyse (for example a compiled php file) like it not even exist, you can right click on file in source tree and select "Mark as Plain Text". This action totally remove any inspections on this file. With this I removed a lot of notifications about "source duplications" in Laravel 5.

If you need to activate it again - once more right click and "Mark as PHP".

This works nice for a few files. If you need to exclude whole directory with everything inside, use directory marking from settings or right click on directory and "Mark Directory As -> Excluded".

Dmitry Sichev
  • 321
  • 3
  • 3
6

There is alternative solution. You can add «read-only» libraries to Include pathin Settings » PHP section.

It is not the same with php.ini include_path option, just referencing to some dirs as external, outside of your control. Exactly what you need.

As result

  • no problems with scopes defining, just inspect whole project, if needed
  • no useless version control overhead in libs
  • This also seems to work for javascript. I added a lib folder as a library so jquery and such would not be inspected. – KrekkieD Aug 24 '14 at 20:26
4

If you want to totally exclude a file or folder from completion and code help:
Right click the folder or file in your file browser (left handed) choose "Mark"-> "excluded"

That's what I wanted, I add that answer here because I found this question in Google when looking for an answer.

John
  • 7,507
  • 3
  • 52
  • 52