Sublime Forum

Faulty References/Definitions in Classes (PHP)

#1

I have noticed that when using classes (only in php, haven’t tried out other languages) that definitions and references of functions are displayed regardless of the class they were defined in.

This can sometimes be confusing when you are looking at multiple subclasses and you are referenced to another one or even the parent class because this one does not implement the function.

Is this intended behavior? I find it incredibly annoying and if possible would like to have a switch to “restrict” matches.

0 Likes

#2

I think none of the autocompletion in ST is context-aware because ST usually suggest several same-name classes. If you want some static analysis, use LSP then.

0 Likes

#3

@ jfcherng, I use LSP and I tried it in the same scenario, got the same references… I am not sure LSP even re-defines algorithms for references… Unless there is something I am missing?

0 Likes

#4

What do you mean “I use LSP”? I ask this because using LSP is just not like “simply install the LSP package”. There are steps to setup the corresponding LSP server. See the docs.

You would have to

  • Install a PHP language server (Intelephense or PHP Language server)
  • Setup the language server

I personally recommend Intelephense because it has a fast response. PHP Language server is slow when I tried it last year. But Intelephense is implemented in Node.js so you have to install it as well.

0 Likes

#5

Yes, I know, I have installed the php server (the first one on the docs) and I also got the fancy overlay, though I just rechecked and I probably hadn’t properly activated it at the time I checked because now it works… my fault :sweat_smile:

0 Likes

#6

Maybe it just takes some time to do indexing things. rename is not implemented in Intelephense. So if you need it, go PHP Language server then. :sweat_smile:

0 Likes