raoulsson
raoulsson

Reputation: 16365

Intellij PHP Import Highlighting

IntelliJ IDEA usually highlights classes that are not imported through the use keyword right before the class declaration. You can then ctrl-enter to insert the use import automatically.

It works on most of my projects, but not in all. Any idea where this can be set?

Without the import

IntelliJ recognizes and suggests

After ctrl-enter, it is added

I use Version 15.0.3, Build #UI-143.1821 and the latest PHP Plugin.

Upvotes: 0

Views: 126

Answers (2)

raoulsson
raoulsson

Reputation: 16365

Vladimir Luchansky wrote on the IntelliJ bugtracker:

Enable

File | Settings | Editor | Inspections > PHP | Undefined | Undefined class

it will bring back "Import class" intention.

That solves it.

How did it happen?

Turns out, I turned this inspection off when trying to get rid of a "multiple implementations exist" message (cannot avoid)

enter image description here

...and then:

enter image description here

Upvotes: 1

alumarcu
alumarcu

Reputation: 131

I have PhpStorm but I assume the settings look the same in Intelij IDEA with PHP plugin. That is, you should be able to find it under Settings > Editor > General > AutoImport. (Just search for "auto-import")

Importing in Intellij/PHPStorm

But it also may be that the location of that certain file cannot be found by PhpStorm/IntelliJ and you need to add it to your include path.

Upvotes: 1

Related Questions