taoso / phpcd.vim

phpcd - A Intelligent/Smart PHP Complete Daemon Plugin for Vim/NeoVim
https://github.com/taoso/phpcd.vim
Apache License 2.0
389 stars 45 forks source link

Not working on php-7.4 #181

Closed nagaho closed 4 years ago

nagaho commented 4 years ago

PHPCD.DEBUG: ErrorException: Function ReflectionType::__toString() is deprecated in PHPCD.php:847

taoso commented 4 years ago

I used php-7.4.2 and https://github.com/lvht/phpcd.vim/commit/0f56ec88fd419cbd772e9052a60e8c376a766442

It works fine.

You might need test the latest phpcd.

nagaho commented 4 years ago

It works with the following modifications.

PHPCD.php
@@ -844,7 +844,7 @@ class PHPCD implements RpcHandler
         if ($hintedClass) {
             $paramString .= $hintedClass->getName() . ' ';
         } elseif (method_exists($param, 'hasType') && $param->hasType()) {
-            $paramString .= $param->getType() . ' ';
+            $paramString .= $param->getType()->getName() . ' ';
         }
         $paramString .= '$' . $param->getName();
         if (!$param->isDefaultValueAvailable()) {
@@ -879,7 +879,7 @@ class PHPCD implements RpcHandler
         }
         $returnType = '';
         if (method_exists($method, 'getReturnType') && $method->hasReturnType()) {
-            $returnType = " : " . (string)$method->getReturnType();
+            $returnType = " : " . (string)$method->getReturnType()->getName();
         }
         $docblock = $this->clearDoc($method->getDocComment());
         return sprintf(
taoso commented 4 years ago

thank you