Peekmo / atom-autocomplete-php

Autocomplete for PHP in atom editor
MIT License
136 stars 34 forks source link

Function ReflectionType::__toString() is deprecated #412

Open alvarose opened 4 years ago

alvarose commented 4 years ago

Whenever I open a php file I get this error:

Failed to get methods for App\HomeController.php
Function ReflectionType::__toString() is deprecated
orukaz commented 4 years ago

I think this line is making this error:

https://github.com/Peekmo/atom-autocomplete-php/blob/master/php/services/Tools.php

$result['return']['type'] = method_exists($function, 'getReturnType') && $function->hasReturnType() // PHP7             
? $function->getReturnType()->__toString()             
: $result['return']['type']         
;

I think it should be replaced with:

https://github.com/event-engine/php-data/pull/2/commits/e8daa9e1f6673238d18b626526acde96fca097fb

$returnType = $method->getReturnType();
$type = $returnType->getName();

Final result should be:

$result['return']['type'] = method_exists($function, 'getReturnType') && $function->hasReturnType() // PHP7             
? $function->getReturnType()->getName()             
: $result['return']['type']         
;
orukaz commented 4 years ago

I haven't tested if it but I made some first changes for testing purposes:

https://github.com/orukaz/atom-autocomplete-php/blob/master/php/services/Tools.php

alvarose commented 4 years ago

Hi friend! Did you test it? How can I check if that works? Good job!

alvarose commented 4 years ago

I've tried it and it works! Just put this line as you said and voila !:

? $function->getReturnType()->getName()