IntelliJ Suggests Undeclared Properties — Can This Behavior Be Customized?

Answered

Hi everyone,

I’m looking for a way to fine-tune IntelliJ’s auto-completion behavior and would appreciate your insights.

The situation:

When working in PHP (and similarly in Kotlin and Java), I’ve noticed that IntelliJ suggests completions for class properties that haven’t been declared yet. For example, when I type $this->empl, IntelliJ offers suggestions like employeeService, even though that property doesn’t currently exist in the class.

If I press “Enter,” it not only completes the line but also adds that dependency to the constructor automatically. While I understand this can be helpful in some cases, it’s usually not what I intend — most of the time, it’s just a typo, like intending to write $this->serv(ice) instead.

What I’m hoping to achieve:

Ideally, I’d like IntelliJ to only suggest completions for properties or variables that already exist in the current context, rather than proposing potential dependencies or external classes. This would help avoid unintentional constructor changes and reduce noise in the suggestions list. Is there a setting or approach in IntelliJ that allows limiting suggestions to declared properties only, without proposing undeclared or injectable classes?

0
3 comments

Hi, 

Can you try to disable these AI completion options bellow (Settings | Editor | General | Inline Completion) and any AI plugins if installed in File | Settings | Plugins | Installed tab? Please share the outcome. 

If the issue persists, please trigger code completion where the incorrect suggestions appear and share a screenshot of this completion prompt before accepting it. This will help us determine whether the suggestions are coming from the AI plugin or from another code completion mechanism.

 

0

Hi!

I've already disabled all AI plugins, so the "Inline Completion" settings page is completely blank on my end. I'll attach a screenshot of the relevant settings for reference.

Even with almost all settings disabled, I'm still receiving suggestions for non-existent properties (though the classes being suggested do exist).

It's not a huge issue, but perhaps there's a simple solution.

Thanks again for your help!
 

0

Hi Df,

This feature is part of the paid version of the 3rd-party Symfony plugin. You can scroll through the screenshot carousel on the page to view a similar output.

The native PhpStorm functionality will only display this:

If you have any suggestions for the Symfony plugin, feel free to contact the plugin author here.

0

Please sign in to leave a comment.