1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Add PHP 7.0-compatible closure creation

This commit is contained in:
Matthew Brown 2019-02-15 18:33:29 -05:00
parent d76459e138
commit 149d7cab1c

View File

@ -52,7 +52,11 @@ class FunctionReturnTypeProvider
*/
public function register(string $class)
{
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;