https://github.com/phpactor/language-server-protocol
https://github.com/phpactor/language-server-protocol
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/phpactor/language-server-protocol
- Owner: phpactor
- License: other
- Created: 2020-06-14T12:31:38.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-12-24T17:51:00.000Z (about 1 year ago)
- Last Synced: 2025-04-30T18:09:46.718Z (8 months ago)
- Language: PHP
- Size: 715 KB
- Stars: 12
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
PHP Language Server Protocol Generator
======================================

This package _transpiles_ the `vscode-language-server-protocol` library to PHP,
providing the protocol classes required to create Language Server
with PHP.
Notes on using the library
--------------------------
Most (if not all) of the upstream Typescript types have no constructors,
therefore the argument order of the constructors can change on _every
release_.
It is therefore **strongly recommended** to use named arguments.
Generation
----------
Generating the code:
- `npm run generate`: Build and transpile
- `npm run watch`: Watch and compile on Typescript changes.
Running the PHP tests:
- `composer integrate`
Usage
-----
### Deserialization
This library will use the type information form typescript to generate
`fromArray` static constructors for each type:
```php
$item = CompletionItem::fromArray([
'label' => 'Foobar',
'kind' => 1,
'detail' => 'This is foobar',
'documentation' => [
'kind' => 'markdown',
'value' => 'Foobar',
],
'additionalTextEdits' => [
[
'range' => [
'start' => [
'line' => 5,
'character' => 10,
],
'end' => [
'line' => 10,
'character' => 10,
],
],
'newText' => 'Foobar',
],
],
'command' => [
'title' => 'Foobar',
'command' => 'my.command',
],
]);
```
Will return a fully hydrated completion item with concrete sub-types.
**NOTE**: that when deserializing from a language server client request, it is
probably a good idea to ignore additional parameters (the second argument to
`fromArray`). This is because it is perfectly valid to pass unknown properties
to some of the LSP objects.
### Serialization
Properties in classes are public to enable JSON serialization. Call
`json_encode($lspObject)` to get the valid LSP JSON object.
Contributing
------------
This package is open source and welcomes contributions! Feel free to open a
pull request on this repository.
Support
-------
- Create an issue on the main [Phpactor](https://github.com/phpactor/phpactor) repository.
- Join the `#phpactor` channel on the Slack [Symfony Devs](https://symfony.com/slack-invite) channel.