marlonfan / coc-phpls

🐭 php language server for coc.nvim
MIT License
212 stars 16 forks source link

Undefined functions, types, etc. #50

Closed Artem-Schander closed 6 months ago

Artem-Schander commented 4 years ago

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

marlonfan commented 4 years ago

Let me check. Thanks for your feedback

marlonfan commented 4 years ago

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

Can you solve your problem?

Artem-Schander commented 4 years ago

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

dvaqueiro commented 4 years ago

Same issue: image

dvaqueiro commented 4 years ago

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

Cvar1984 commented 4 years ago

I have the same problem on neovim for termux

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

Artem-Schander commented 4 years ago

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
},
cxgslegend commented 4 years ago

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 commented 4 years ago

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.

alalfakawma commented 4 years ago

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.

artfulrobot commented 3 years ago

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, ...!

xbot commented 3 years ago

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

nake89 commented 2 years ago

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.

xebcam commented 2 years ago

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.

Artem-Schander commented 2 years ago

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.