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);
    }