atom-autocomplete-php icon indicating copy to clipboard operation
atom-autocomplete-php copied to clipboard

Function ReflectionType::__toString() is deprecated

Open alvarose opened this issue 4 years ago • 4 comments

Whenever I open a php file I get this error:

Failed to get methods for App\HomeController.php
Function ReflectionType::__toString() is deprecated

alvarose avatar Apr 16 '20 11:04 alvarose

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 avatar Jun 23 '20 18:06 orukaz

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

orukaz avatar Jun 23 '20 18:06 orukaz

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

alvarose avatar Jul 02 '20 10:07 alvarose

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

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

alvarose avatar Jul 03 '20 19:07 alvarose