Handle PHPStorm correctly "there are several class definitions"

I am currently working on a PHP project that the composer uses to manage third-party dependencies. This project has a sub-project /installer , which, as the name implies, contains a small tool that handles the installation and initial setup of the "main" project. The installer tool also uses the composer to handle its dependencies, which are stored separately from the main project files.

For convenience, these two projects are part of the same git project and, as such, in the same PHPStorm project. Since the dependencies of both projects sometimes overlap, I often get the warning “Multiple class definitions”. Although this is neither a surprise nor a serious problem, I would like to know if there is a way to tell PHPStorm "hey, treat everything inside /installer as an independent project and not cross-check classes with the outer scope`.

thanks

+6
source share
3 answers

You can disable this check (works at least for PHPStorm 9.0 or later):

Settings → Editor → Inspections → PHP → Undefined → Undefined class

Uncheck Options (bottom right) → Do not report potential problems with class declarations

+8
source

You can specify the directory as Excluded , so PHPStorm will simply hide it and stop the index files inside, so there are no warnings. But at the same time it will be impossible to view (read) that files.

Right-click the directory (in your case /installer ) in the Project pane and select Mark Directory As -> Excluded

+3
source

You can right-click the files in Project Explorer and mark them as "Plain Text" so that these classes are not interpreted as source code.

Best way: use namespace

0
source

All Articles