protected static function closure($context, $closure) {
        if (is_string($closure) && preg_match('/(.+)::(.+)/', $closure, $matched)) {
            $ref = new \ReflectionMethod($matched[1], $matched[2]);
        } else {
            $ref = new \ReflectionFunction($closure);
        }
        $meta = static::getMeta($ref);

        return preg_replace('/^.*?function(\s+[^\s\\(]+?)?\s*\\((.+)\\}.*?\s*$/s', 'function($2}', static::replaceSafeString($context, $meta['code']));
    }
protected static function closure($context, $closure) {
        if (is_string($closure) && preg_match('/(.+)::(.+)/', $closure, $matched)) {
            $ref = new \ReflectionMethod($matched[1], $matched[2]);
        } else {
            $ref = new \ReflectionFunction($closure);
        }
        $meta = static::getMeta($ref);

        return preg_replace('/^.*?function(\s+[^\s\\(]+?)?\s*\\((.+)\\}.*?\s*$/s', 'function($2}', static::replaceSafeString($context, $meta['code']));
    }
protected static function closure ( $ context , $ closure ) { if ( is_string ( $ closure ) && preg_match ( '/(.+)::(.+)/' , $ closure , $ matched ) ) { $ ref = new \ ReflectionMethod ( $ matched [ 1 ] , $ matched [ 2 ] ) ; } else { $ ref = new \ ReflectionFunction ( $ closure ) ; } $ meta = static :: getMeta ( $ ref ) ; return preg_replace ( '/^.*?function(\s+[^\s\\(]+?)?\s*\\((.+)\\}.*?\s*$/s' , 'function($2}' , static :: replaceSafeString ( $ context , $ meta [ 'code' ] ) ) ; }
Get PHP code string from a closure of function as string

@param array<string,array|string|integer> $context current compile context
@param object $closure Closure object

@return string

@expect 'function($a) {return;}' when input array('flags' => array('standalone' => 0)),  function ($a) {return;}
@expect 'function($a) {return;}' when input array('flags' => array('standalone' => 0)),   function ($a) {return;}
Get PHP code string from a closure of function as string