private function extractClosureNamespaces(\Closure $closure)
    {
        $function = new \ReflectionFunction($closure);
        if ($function->getFileName() === false || strpos($function->getFileName(), 'eval()\'d code') !== false) {
            return [
                'namespace' => null,
                'uses' => [],
            ];
        }

        $tokens = token_get_all(implode(array_slice(file($function->getFileName()), 0, $function->getEndLine())));
        return $this->extractNamespaces($tokens);
    }
private function extractClosureNamespaces(\Closure $closure)
    {
        $function = new \ReflectionFunction($closure);
        if ($function->getFileName() === false || strpos($function->getFileName(), 'eval()\'d code') !== false) {
            return [
                'namespace' => null,
                'uses' => [],
            ];
        }

        $tokens = token_get_all(implode(array_slice(file($function->getFileName()), 0, $function->getEndLine())));
        return $this->extractNamespaces($tokens);
    }
private function extractClosureNamespaces ( \ Closure $ closure ) { $ function = new \ ReflectionFunction ( $ closure ) ; if ( $ function -> getFileName ( ) === false || strpos ( $ function -> getFileName ( ) , 'eval()\'d code' ) !== false ) { return [ 'namespace' => null , 'uses' => [ ] , ] ; } $ tokens = token_get_all ( implode ( array_slice ( file ( $ function -> getFileName ( ) ) , 0 , $ function -> getEndLine ( ) ) ) ) ; return $ this -> extractNamespaces ( $ tokens ) ; }
Returns Closure's namespace and uses.
@param \Closure $closure
@return array
Returns Closure s namespace and uses .