If you're not familiar with the goals of the PXP project, I recommend reading the introductory blog post first.
In a truly ideal world PXP would have been an extension for an existing language server, but since PXP requires a separate parser with support for all of the new syntax, it's not really that easy.
My goal is to develop a brand new language server for PHP and PXP development - 100% open source and free to use.
A large majority of PHP developers use PhpStorm as their main development environment. The latest release of PhpStorm and other IntelliJ tools have introduced support for the Language Server Protocol, which means the language server that I'm developing can actually be used inside of PhpStorm for PXP development.
Now that it's feasible to have PXP support inside of PhpStorm, I'm aiming to have the first release of the language server, a Visual Studio Code plugin and PhpStorm plugin by September 8th. That is 1 month from the publishing of this blog post and as such, I'd like to outline the things the language will be able to do upon release and how it will progress.
Language server development isn't necessarily hard, it's just time consuming and involves a lot of manual testing. As such, the initial release is solely focused on nailing a handful of features.
The first feature is of course autocompletion. We rely very heavily on intelligent autocompletion and suggestions these days, so getting this good is important.
PLS will have support for the following things:
- Variable suggestions
- Object property access and method calls
- Static property access and method calls
- Class constants and enumeration cases
- Global constants set through
- Use statement completion
- Class extends, implements and use suggestions
- Simple keyword suggestions (not context specific)
- Virtual method and property suggestions from class-level DocBlock comments (
The list above is everything that I deem required for a language server to be usable.
Something that isn't mentioned above is support for generics. Generics are complex and require more in-depth tracking of how you call class methods, update properties and interact with data. They are also a relatively new thing in other language servers, so I've pushed this to the bottom of the list for the initial release.
Go to Symbol (File)
I find myself using this one a lot. When you open the "File Explorer" widget in Visual Studio Code using Cmd+P, you can place
@ at the start and it will give you a list of various symbols in the file (classes, functions, variables, etc).
Support for this will be fairly basic and provide a list of basic definitions like class-like structures, methods, properties and functions.
The language server will provide simple diagnostics based on parser errors. These will tell you about missing characters and bad syntax in your files.
There will also be an additional diagnostics provider for PHPStan. This will only be enabled if a
phpstan.neon file is found in the root of your project.
PHPStan isn't really designed for IDE usage. It can be quite slow on large projects, so I do also plan to implement a very minimal static analyser in a future release, mostly focused on missing parameters, incorrect types, etc. Simple analysis rules but ones that can still be useful to see quickly after changing a file.
Hovering over function names, properties, etc is useful for seeing a list of parameters and return types. Again, an essential feature in a language server for myself and I imagine others too.
Go to Definition
This one is also useful for quickly jumping around a project. Support will be limited to just variables, class names and class members.
The language server won't come with a dedicated formatter but will provide integrations with PHP-CS-Fixer and Laravel Pint. These are tools that I use myself and you likely also use them in your projects, so it makes sense to avoid any unnecessary self-rolled implementations.
With the feature set above on release, the first goal will be making sure that it's stable and squashing any issues people run into.
From there, my next focus will be adding support for generics. I can foresee a number of refactoring opportunities with the current codebase and implementing support for generics will most definitely highlight those.
Once generics are implemented and likely released on their own, I'll then look to the community and ask for feature ideas, whether it's improving on the features that the language server already has or implementing new mechanisms to improve developer experience.
I'm really excited to release the language server and work on it for the foreseeable.