Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code suggestions for PHP show everything, instead of class functions only

I tried setting up VS Code for a legacy PHP project, to evaluate it against other IDEs. My problem is with the suggestions I get, when I press <an object>->Ctrl+Space. For example I want to get all suggestions (properties and functions) of a certain class. I am in the class and I type:

$this->(Ctrl+Space)

I get a large list of functions and constants, which are things I can use in PHP in general and not the functions and properties of the class I am in. After I installed the PHP Intelephense extension, I get the class methods that I need in my suggestions, but still they are mixed with everything else and hard to find, unless I start typing the first letters of the function I need to access. To show you what I mean, this is what I get, when I type the following within a function of my class:

enter image description here

I don't think this is a matter of extension, because even if I disable all my extensions I still get the whole bunch of suggestions. How can I remove all unnecessary suggestions, or at least give priority to the class specific suggestions and see them on top of the list?

like image 496
Stefanos Kargas Avatar asked Jul 01 '19 09:07

Stefanos Kargas


People also ask

How do I enable autocomplete in Visual Studio?

The suggestion list of Automatic completion appears as soon as you start typing a new identifier. The suggestion list of Basic completion appears when you press the default Visual Studio IntelliSense shortcut Ctrl+Space .

How do I turn on IntelliSense?

You can enable or disable particular IntelliSense features in the Options dialog box, under Text Editor > C/C++ > Advanced. To configure IntelliSense for single files that aren't part of a project, look for the IntelliSense and browsing for non-project files section.


1 Answers

I've been struggling with this for while too ...

You can just disable the basic PHP suggestions by setting php.suggest.basic to false in your settings.json file or use the settings UI at PHP > Suggest: Basic

With Intelephense installed everything works as expected now !

source : https://code.visualstudio.com/docs/languages/php#_disable-builtin-php-support

like image 139
Kriss2 Avatar answered Oct 05 '22 23:10

Kriss2