From 149d7cab1cc690f3b927c97f281b4d977038c09a Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Fri, 15 Feb 2019 18:33:29 -0500 Subject: [PATCH] Add PHP 7.0-compatible closure creation --- src/Psalm/Internal/Provider/FunctionReturnTypeProvider.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Provider/FunctionReturnTypeProvider.php b/src/Psalm/Internal/Provider/FunctionReturnTypeProvider.php index e7d94bf71..0c32cf624 100644 --- a/src/Psalm/Internal/Provider/FunctionReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/FunctionReturnTypeProvider.php @@ -52,7 +52,11 @@ class FunctionReturnTypeProvider */ public function register(string $class) { - $callable = \Closure::fromCallable([$class, 'get']); + if (version_compare(PHP_VERSION, '7.1.0') >= 0) { + $callable = \Closure::fromCallable([$class, 'get']); + } else { + $callable = (new \ReflectionClass($class))->getMethod('get')->getClosure(new $class); + } foreach ($class::getFunctionIds() as $function_id) { self::$handlers[$function_id] = $callable;