coc-phpls
coc-phpls copied to clipboard
Undefined functions, types, etc.
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:
- Install Neovim and use my config and my coc-settings
- Install a regular Laravel Project and install and run barryvdh/laravel-ide-helper
- (optional) Install some other Packages (GraphQL or whatever you want)
- Use some stuff from the vendor folder, or even use some laravel functions like
abortorapp - See the undefined messages
Expected behavior I'd expect the functions and classes to be found ^^
Screenshots

Desktop
- OS: macOS 10.15.3 / Linux Manjaro 18
- NVIM v0.4.2

Let me check. Thanks for your feedback
Hi, please try call "CocCommand intelephense.index.workspace" command
Can you solve your problem?
@marlonfan unfortunately it did not help. All errors came back after it said "[coc.nvim] Indexed php files, times: 2338ms"
Same issue:

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

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

I have the same problem on neovim for termux

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
},
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.
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.
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.
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, ...!
I have the same problem and CocCommand intelephense.index.workspace solved it.
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.
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.
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.