On a legacy project, the lsp indexes the entire project (can see the message in neovim), but all imported classes show a Class 'Name\Space\Here' not found error message in the buffer (pic below). Also, hover/docs signature does not work.
Environment
- PHPantom: 0.6.0
- Neovim built-in LSP
- Docker Compose dev env
- PHP 7.4.33 (I know, we need to update it)
- Project uses Composer with a mix of:
autoload.classmap
autoload.psr-4
- legacy/non-canonical file layout (prior devs on this project were not great)
Project autoload shape
From composer.json:
"autoload": {
"classmap": [
"app/controllers",
"app/models",
"app/legacy"
],
"psr-4": {
"Controllers\\Registration\\": "app/controllers/",
"LegacyBoundedContexts\\": "LegacyBoundedContexts",
....
}
}
Example
Composer maps:
"Controllers\\Registration\\": "app/controllers/"
But the file is actually at:
app/controllers/registration/RegistrationController.php
And the file declares:
<?php
namespace Controllers\Registration;
class RegistrationController
{
}
So navigation can find it, but hover/diagnostics still behave as if the class cannot be resolved.
Another example that resolves by navigation
<?php
namespace Controllers\Registration;
use LegacyBoundedContexts\AMS\Registration\AthleteSelectsDisciplines\Factory\AthleteRegistrationFactory;
use LegacyBoundedContexts\AMS\Registration\AttentionRequired\ApplicationServices\RegistrationWorkflow\RegistrationWorkflow;
use Service\AuthenticationService;
In this file:
- go-to-definition works on these imports/usages
- hover is missing or incomplete
- diagnostics still report class-not-found errors
Neovim :checkhealth vim.lsp shows phpantom as the only php lsp running and attached to the buffer.
What I suspect (I'm probably wrong, but this is what I gathered from a quick read through of some of the source code)
It seems like the symbol index is good enough for navigation, but the deeper semantic resolution path used by hover/diagnostics is stricter and does not fully handle this kind of classmap-heavy / non-canonical Composer layout.
Let me know if you have any additional questions or need more information.
Thanks for all your hard work on this! I'm soooo pumped to finally have a real LSP for PHP!
On a legacy project, the lsp indexes the entire project (can see the message in neovim), but all imported classes show a
Class 'Name\Space\Here' not founderror message in the buffer (pic below). Also, hover/docs signature does not work.Environment
autoload.classmapautoload.psr-4Project autoload shape
From
composer.json:Example
Composer maps:
But the file is actually at:
And the file declares:
So navigation can find it, but hover/diagnostics still behave as if the class cannot be resolved.
Another example that resolves by navigation
In this file:
Neovim
:checkhealth vim.lspshows phpantom as the only php lsp running and attached to the buffer.What I suspect (I'm probably wrong, but this is what I gathered from a quick read through of some of the source code)
It seems like the symbol index is good enough for navigation, but the deeper semantic resolution path used by hover/diagnostics is stricter and does not fully handle this kind of classmap-heavy / non-canonical Composer layout.
Let me know if you have any additional questions or need more information.
Thanks for all your hard work on this! I'm soooo pumped to finally have a real LSP for PHP!