coc-phpls icon indicating copy to clipboard operation
coc-phpls copied to clipboard

Undefined functions, types, etc.

Open artem-schander opened this issue 5 years ago • 15 comments

Describe the bug It seems that the plugin is not able to find the definitions. I get all kind of undefined ... errors. However the Intelephense plugin for VS Code works just fine. See screenshots.

To Reproduce Steps to reproduce the behavior:

  1. Install Neovim and use my config and my coc-settings
  2. Install a regular Laravel Project and install and run barryvdh/laravel-ide-helper
  3. (optional) Install some other Packages (GraphQL or whatever you want)
  4. Use some stuff from the vendor folder, or even use some laravel functions like abort or app
  5. See the undefined messages

Expected behavior I'd expect the functions and classes to be found ^^

Screenshots Bildschirmfoto 2020-02-16 um 15 51 59 Bildschirmfoto 2020-02-16 um 15 52 41

Desktop

  • OS: macOS 10.15.3 / Linux Manjaro 18
  • NVIM v0.4.2 Bildschirmfoto 2020-02-16 um 16 10 34

artem-schander avatar Feb 16 '20 15:02 artem-schander

Let me check. Thanks for your feedback

marlonfan avatar Feb 25 '20 03:02 marlonfan

Hi, please try call "CocCommand intelephense.index.workspace" command

Can you solve your problem?

marlonfan avatar Feb 25 '20 05:02 marlonfan

@marlonfan unfortunately it did not help. All errors came back after it said "[coc.nvim] Indexed php files, times: 2338ms"

artem-schander avatar Feb 25 '20 08:02 artem-schander

Same issue: image

dvaqueiro avatar Apr 11 '20 13:04 dvaqueiro

Sorry, i solve my last commented issue. The class WebTestCase is under a Test folder. In your package.json is image

But i think i can override with :CocConfig and writing somethig like image

dvaqueiro avatar Apr 11 '20 14:04 dvaqueiro

I have the same problem on neovim for termux

Screenshot_2020-07-07-19-59-06-626_com termux

Cvar1984 avatar Jul 07 '20 12:07 Cvar1984

Yeah, it would be nice if someone could fix this. For now I disabled all the broken stuff.

"intelephense.diagnostics": {
    "undefinedTypes": false,
    "undefinedFunctions": false,
    "undefinedConstants": true,
    "undefinedClassConstants": true,
    "undefinedMethods": false,
    "undefinedProperties": false,
    "undefinedVariables": false
},

artem-schander avatar Jul 08 '20 17:07 artem-schander

I am also having issues with this. I am using Laravel, and all of the model classes are undefined.

Don't get me wrong, I expect the php integration will have a lot of issues. Even intellij struggles working with all of Laravels magic methods. But there are just too many errors to be able to comfortably work.

I think in theory it should at least be able to give the same errors as the vscode intelephense lsp.

Screen Shot 2020-07-09 at 3 20 04 PM

cxgslegend avatar Jul 09 '20 19:07 cxgslegend

I actually retract what I said before. I have vim rooter, and startify installed. I thought vim rooter was setting the correct root, but startify was overriding that. When the correct project root was set, these errors went away. I apologize for incorrectly reporting this as a phpls error.

cxgslegend avatar Jul 10 '20 14:07 cxgslegend

I'm also working on a Laravel project and it is unable to find the Str class specifically in the Controllers namespace. When working on an Resource, it did detect and import the Str class. But now it is impossible. I really wish it would be fixed soon.

alalfakawma avatar Aug 31 '20 16:08 alalfakawma

Hi, please try call "CocCommand intelephense.index.workspace" command

Workspaces are a mystery to me, I think it's supposed to be the top-level dir under which everything is indexed, right? But I have no idea how to set it for a given file. But this command fixed it for me, I'm just not sure what it did/does!

It would be great if the README of this project gave some more documentation to; even if that's just links to other projects. It's not clear when there's a problem if it's this, Coc, Intelephense, ...!

artfulrobot avatar Oct 30 '20 07:10 artfulrobot

I have the same problem and CocCommand intelephense.index.workspace solved it.

xbot avatar Jun 08 '21 09:06 xbot

I had a similar problem of undefined types. The problem was that the file I wanted to edit was in a subdir. This meant that intelephense only indexed the filed of that dir. I then opened my file in the root of the project e.g. vim path/to/file/myfile.php. Hopefully this helps somebody.

nake89 avatar Oct 07 '21 09:10 nake89

Apparently you need to initialize the project with git in order for the extension to work as expected (At least in laravel projects) . I had the same problem but once I did a git init on the root of the project now I don't get Undefined types, functions, etc. I discovered this because I installed another similar extension coc-intelephense and it worked on one project but not the other, then realized that the project in which that extension worked was a git repo.

xebcam avatar Mar 31 '22 03:03 xebcam

All of my projects are git projects from the very beginning and I believe I also had coc-intelephense installed. This is/was not the issue. I'm not using coc anymore .. so maybe something changed.

artem-schander avatar Mar 31 '22 06:03 artem-schander