diff --git a/php/ErrorHandler.php b/php/ErrorHandler.php index 7c5f1a7..53b0027 100644 --- a/php/ErrorHandler.php +++ b/php/ErrorHandler.php @@ -29,20 +29,19 @@ public static function register() set_exception_handler('Peekmo\AtomAutocompletePhp\ErrorHandler::onException'); } - /** - * @throws ErrorException on any error. - */ public static function onError($code, $message, $file, $line, $context) { - throw new \ErrorException($message, $code, 1, $file, $line); + // call onException directly instead of throw'ing + // to work around https://bugs.php.net/bug.php?id=66216 + self::onException(new \ErrorException($message, $code, 1, $file, $line)); } /** * Display uncaught exception in JSON. * - * @param \Exception $exception + * @param \Throwable $exception */ - public static function onException(\Exception $exception) + public static function onException(\Throwable $exception) { die( json_encode( diff --git a/php/services/Tools.php b/php/services/Tools.php index a3218f2..496dd25 100644 --- a/php/services/Tools.php +++ b/php/services/Tools.php @@ -212,7 +212,7 @@ protected function getMethodArguments(ReflectionFunctionAbstract $function) ); $result['return']['type'] = method_exists($function, 'getReturnType') && $function->hasReturnType() // PHP7 - ? $function->getReturnType()->__toString() + ? (version_compare(PHP_VERSION, '7.1.0', '>=') ? $function->getReturnType()->getName() : $function->getReturnType()->__toString()) : $result['return']['type'] ;