psalm as the defacto php language server #8328
Replies: 7 comments 22 replies
-
Hey! Thanks for your interest! The situation is exactly the same as described by Matt at that time: #4942 (comment) We would love to get more contributors to Psalm, including for LSP. We've had @tm1000 submitting a serie of PR about that: https://github.com/vimeo/psalm/pulls?q=is%3Apr+author%3Atm1000+is%3Aclosed and maintaining https://github.com/psalm/psalm-vscode-plugin. You're very welcome if you want to help in that regard :) |
Beta Was this translation helpful? Give feedback.
-
Hi there. There is actually a fork of felixbecker/php-language-server from @zobo (see: https://github.com/zobo/php-language-server) who is the maintainer of the xdebug vscode plugin. He and I together worked on an upgrade of functionality to the base library that both Psalm and the language server use for spec reference (see: https://github.com/felixfbecker/php-language-server-protocol). I would say that Zobo's implementation is the spiritual successor to felixbecker's version. He last updated it about a month ago and I know he's looking for contributors. The way Psalm is designed does not lend itself well to several things other LSPs excel at. Namely Psalm does not have to keep a good representation of meta data about variables/functions and classes and the like that would be able to be displayed nicely in an LSP. The reasoning Psalm doesn't do that is because it's not needed in a Static Analyzer. Thus you lose a lot of nice references that exist in say php-language-server or intelephense. Additionally Psalm was never written to be non-blocking. As you know PHP itself is a blocking language. Thus the addition of the LSP on top of it can prove difficult at times because you will be waiting for Psalm to complete some blocking IO process while your IDE just "spins". This really can't be solved without re-writing Psalm completely. The scope of Psalm is not to be an LSP first but to be a static analyzer and I think you have to keep this in mind when you ask for Psalm to be the defacto php language server. It really can't ever do this unless the internal IO functions are abstracted to be non-blocking. You can checkout my fork of Psalm (https://github.com/tm1000/psalm/tree/feature/upgrade-lsp) to see the work I've done to get closer to more LSP options for a better view of what I intend to submit at some point. When I work on my fork I actually disable intelephense but because of the lack of metadata I lose the ability to see a lot of cool things that come from intelephense. So it's definitely not perfect. The only reason I run a fork of Psalm right now is because I am slowly trying to add tests to the LSP that never existed before and adding tests to ampphp is not for the faint-hearted. My fork is updated with Psalm 4.x mainline as of last week. Someday soon I hope to submit it back to the main project. Hope that helps clarify some things and I hope @zobo can add some context as well. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the replies so far, I'll wait and see what zobo has to say but things have definitely been clarified a bit. |
Beta Was this translation helpful? Give feedback.
-
Hi! Great that this topic was opened. I have opinions! I just can't write a coherent post right now as I am still traveling and have very limited time. I will try to gather my thoughts here and a few days. |
Beta Was this translation helpful? Give feedback.
-
@orklah can you convert this to a discussion? Also @unansweredocd what do you mean by slow in reference to "phpactor" It would also be nice to be able to be in discussions with the maintainer of phpactor on this. |
Beta Was this translation helpful? Give feedback.
-
Thank you all for leaving comments, getting all the people that work on this stuff together is great to see. I think it's a good idea to wait for the intelephense maintainer to put his thoughts here like @tm1000 has said. We'll have a broader scope of what's happening in this LSP PHP world. Once that has happened we can talk about the best way forward, super excited about what's happening here! |
Beta Was this translation helpful? Give feedback.
-
Just want to reiterate my own comments linked above: Psalm is primarily designed to be run from the command line. LSP support is a secondary concern. LSP bugs are much harder to reproduce and debug than regular bugs in Psalm's analysis. Due to that friction, I feel that LSP generally lends itself more to paid offerings where maintainers are financially incentivised to spend a lot more time digging into each issue as it comes up. There's technically a very good free and open-source language server for TypeScript, but that only exists because Microsoft has plowed millions of dollars into that project. The Rust Analyzer is also very good, but its creator previously worked at JetBrains before joining Ferrous Systems (where Rust Analyzer was created). The project benefited from big industry support (which Psalm has never had). Unless someone has heavy company sponsorship to work on Psalm's LSP support in an ongoing basis, I don't think it has any right to call itself the "de facto" LSP server. |
Beta Was this translation helpful? Give feedback.
-
Hey folks,
First of all, thanks for the amazing work on psalm. It's a great tool and helps me greatly whenever I work on PHP.
I'm creating this issue because I and others have probably been noticing that the language server part of PHP has been lacking. Several projects are trying to solve the issue but basically all of them lack something or have problems.
To get a better picture of the php language server world I will list all of the ones that I've tried and which issues I ran into.
You probably get the point, a slow, unmaintained or closed source language server isn't cutting it. Paid options are obviously doing okay (see phpstorm) but I think it's time that PHP gets a proper language server without the previously mentioned issues.
This issue is one of my attempts to get the language server issue the attention it deserves. I've send an e-mail to the PHP foundation as you can see below, but that answer is obviously not what we want.
email to php foundation
response from foundation
Besides sending that e-email, there's also this issue on the intelephense repository which is getting some more attention, as you can see lots of folks are saying that they would pay more for intelephense if that meant that it got more support / were open sourced.
So finally that's why I'm here, to ask the maintainers of this project whether psalm can turn into the language server php so desperately needs.
I hope that I didn't use too much of your time to read all this, but issues like #4942 seem to tell me that the interest is there, it just needs people to work on those issues.
So, can psalm be the language server php so desperately needs? Is there anything big blocking it from being so? I’m sure lots of folks would be willing to sponsor in small / big ways to get this done.
Beta Was this translation helpful? Give feedback.
All reactions