Inability to run an Inspection on Composer-installed code?

Hi all,

I wanted to run an inspection on some Composer-installed code located in my vendor directory.  When I right click on the /vendor/some-provider/src folder (in the Project tab), click "Inspect Code" and click the "Analyze" button I get the following:

Code inspection did not find anything to report.  0 files processed in 'Selected Files'.

I know there are files in my local directory, and I know for sure they contain code that is not compatible with PHP8.0. If I open one of the package files directly in the IDE, I get a green "No problems found" checkmark in the upper right corner.  If I then copy/paste that code into a scratch file, it immediately reports 2 errors and 12 warnings from my Inspection profile.

My guess is that PHPstorm excludes non-package files from the Inspect, and I am wondering if there is some way around that?


Comment actions Permalink

Hi there,

Yes, PhpStorm by default treats all composer-installed stuff as a 3rd party/library code (not your own written code), which means no inspections/todos/etc on them.

What you can do:

1. "Settings/Preferences | Directories" -- unmark such a folder as "Excluded" (so it's a "normal" folder)

2. "Settings/Preferences | PHP" -- remove such a folder from the "Include Path"

Now such a folder will be treated as your own code / part of the actual project.


NOTE: if you have "Settings/Preferences | PHP | Composer | Add packages as libraries" option enabled (it is by default) then the next time you open your project the above changes will be removed/restored back.

Comment actions Permalink

Thank you - that sounds promising.  I dont plan on leaving this on forever, but I wanted to one-time scan this abandoned library before we upgrade to PHP8.

Comment actions Permalink

Another approach: just make a new project from existing files and point to the package root folder. This way you will have it as a separate project and can do whatever you want there/keep it for as long as you need. Once done with it, just remove the project from Recent Projects list/Welcome screen and delete .idea subfolder in that place (the project settings).


Please sign in to leave a comment.