Git Product home page Git Product logo

tenkawa-php-language-server's Introduction

Tenkawa PHP Language Server

Tenkawa

Tenkawa is a language server for PHP, with powerful static analysis and type inference engine borrowed without asking from PHPStan.

Still experimental, but should be usable. Any bug reports, feature requests, suggestions, questions are welcome.

Installation

Requires PHP >= 7.1 with pdo_sqlite extension.

For Visual Studio Code extension, see here.

Either with composer create-project (~ directory is an example):

$ cd ~
$ composer create-project --no-dev --keep-vcs \
    tsufeki/tenkawa-php-language-server tenkawa/

Or by cloning the repo:

$ cd ~
$ git clone https://github.com/tsufeki/tenkawa-php-language-server.git tenkawa/
$ cd tenkawa/
$ composer install --no-dev
$ cd ..

Build index of the standard library:

$ php ~/tenkawa/bin/tenkawa.php --build-index

Now configure your client to start the server with this command to use stdio:

php ~/tenkawa/bin/tenkawa.php

Or to connect to a TCP socket:

php ~/tenkawa/bin/tenkawa.php --socket=tcp://127.0.0.1:12345

Features

  • ✔ Autocompletion
    • ✔ Classes/functions (also with automatic import and within doc comments)
    • ✔ Class members
    • ✔ Local variables
  • ✔ Diagnostics
  • ✔ Go to definition
  • ✔ Go to implementation
  • ✔ Hover info
  • ✔ Signature help
  • ✔ References
  • ✔ Document symbols
  • ✔ Workspace symbols
    • ✔ Classes/functions/consts
    • ✘ Class members (not yet)
  • ✔ Code actions
    • ✔ Import class/function
    • ✔ Fix wrong autoloaded class/namespace name
    • ✘ More to come...
  • ✔ Multi-root workspace
  • ✔ Snippets
    • ✔ Class/interface/trait
  • ✔ Dynamic configuration

Unimplemented (yet?):

  • ✘ Go to type definition
  • ✘ Go to declaration
  • ✘ Document highlight
  • ✘ Document link
  • ✘ Code lens
  • ✘ Formatting
    • ✘ document
    • ✘ range
    • ✘ on type
  • ✘ Rename
  • ✘ Folding range

Known issues

  • Many features don't work inside traits. This is caused by PHPStan's design.
  • Refactors are not 100% bullet-proof.
  • Performance & long indexing times.

Command line options

  • --socket=<socket> - connect to a socket instead of communicating through STDIO. Allowed format: tcp://127.0.0.1:12345 or unix:///path/to/socket.
  • --log-stderr - log to stderr.
  • --log-file=<file> - log to the given file.
  • --log-client - log using window/logMessage protocol method.
  • --log-level=<level> - log only messages of the given level and up. <level> can be one of emergency, alert, critical, error, warning, notice, info, debug. Defaults to info.
  • --build-index - build standard library index instead of starting the server.
  • --config-json=<json> - default options, see Configuration. Example: --config-json={"completion":{"autoImport":false}}.

Configuration

You can pass configuration options to the server through initializationOptions parameter of initialize protocol method or by implementing workspace/configuration request and sending workspace/didChangeConfiguration notifications from client.

Recognized options:

{
  "tenkawaphp": {
    "diagnostics": {
      "phpstan": {
        // Enable PHPStan diagnostics.
        "enabled": true
      }
    },
    "completion": {
      // Enable automatic import (use) of completed classes.
      "autoImport": true,
      // By default, only some PHP extensions are used for autocompletion.
      // Additional ones can be enabled here.
      "extensions": ["mysqli", "redis"]
    },
    "index": {
      // Additional stubs directories
      "stubs": ["/path/to/stubs/dir"]
    }
  }
}

Licence

Copyright (c) 2017 tsufeki

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

tenkawa-php-language-server's People

Contributors

benedyktbla avatar dependabot-support avatar tsufeki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tenkawa-php-language-server's Issues

Goto method definition bug when mixed type

when i declare a var with mixed class (A|B or A&B), the method test which exists class A only, can not be intelesense from the call by this var.

<?php
class A
{
    public function test()
    {
    }
}

class B
{
}

/**
 * @var A|B
 */
$x = new A;
$x->test();

and an error occur

2018-12-16T15:45:39+00:00 pid=86702 ERROR Exception during PHPStan analysis: PHPStan\Broker\ClassNotFoundException: Class \A was not found while trying to analyse it - autoloading is probably not configured properly. in /Users/***/.vscode/extensions/tsufeki.tenkawa-php-0.3.3/vendor/tsufeki/tenkawa-php-language-server/src/Tsufeki/Tenkawa/Php/PhpStan/IndexBroker.php:182

But if i declare the var as single type, or just put same method at the class B, it works fine.

Problems in loaded and import

It takes a long time to load the basics of vs code study popr example colocon fun should load the normal public function as it does without plugin but it stays loaded...

With the extension lasts more than 10 minutes:
imagen

Auto import of open bracket on complete

Some options for disable auto import of open bracket on complete?
Problem is: ex function/method: array_merge(
But I should be: ex function/method: array_merge

Sorry for bad English...

Thanks!

PHP 7.4 Exception - ReflextionType::__toString() is deprecated

This is an error I get when I run server with latest PHP version 7.4

2019-12-03T14:20:02+01:00 pid=522980 ERROR Unhandled exception in strand #1: ErrorException (Function ReflectionType::__toString() is deprecated).
    ErrorException: Function ReflectionType::__toString() is deprecated in /tmp/tenkawa-php-language-server/vendor/tsufeki/hmcontainer/src/Tsufeki/HmContainer/Wiring/Wiring.php:92

No indexing with LanguageClient-neovim

I'm attempting to use this language server with LanguageClient-neovim. It appears to work for the file/s I have open (I get diagnostics/completion) however it doesn't seem to be award of/indexing any other files in the project (or the phpstorm stubs, as it tells me built in php functions don't exist edit: fixed this with --build-index). The client does send a rootPath and rootUri in the initialize method message. Is there something else that needs to be done to trigger indexing?

Refactoring Issues on windows

Running Windows.

The folders Http and Controllers starts with a capital letter as seen in the Explorer, but it still come up as an 'error'

image

Go to definition it doesn't update metadata

I changed the name of a file and then renamed to the original name again, and this happens:

image

The old file still appears as a candidate to go to.

Versions

  • OS: Windows 10.
  • PHP Version: 7.3.7.
  • VSCode: 1.38.1.
  • Tenkawa plugin: 0.4.4.

slow indexing

hi guys, some way to exclude the path from indexing, it is very slow when i have more than 1 repository in my project:

image

Allow to change phpstan rule level

Is it possible to analyse codebase with stan using --level argument? In many other editor extensions there is such option, but this awesome ls lacks it.

annotation supports not complete

Hello, there is an awesome php lang server. but i found something not perfect

  • many types combine. eg: * @param FirstInterface|SecondInterface $interface
  • array type define. eg: * @param FirstInterface[]|array $interfaces, it means $interfaces should be an array, and each might be FirstInterface

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.