private function extractNamespaces(array $tokens)
    {
        $closureNamespace = null;
        $closureUses = [];
        $state = null;
        $namespace = null;
        $alias = null;
        foreach ($tokens as $token) {
            if (is_array($token)) {
                if ($state === null && ($token[0] === T_NAMESPACE || $token[0] === T_USE)) {
                    $state = $token[0];
                    $namespace = '';
                } elseif ($state === T_USE && $alias === null && $token[0] === T_AS) {
                    $alias = '';
                } elseif ($state !== null && ($token[0] === T_STRING || $token[0] === T_NS_SEPARATOR)) {
                    if ($alias !== null) {
                        $alias .= $token[1];
                    } else {
                        $namespace .= $token[1];
                    }
                }
            } else {
                if ($state !== null && ($token === ';' || $token === '{')) {
                    if ($alias === null) {
                        if ($state === T_NAMESPACE) {
                            $closureNamespace = $namespace;
                            $closureUses = [];
                        } else {
                            $closureUses[] = $namespace;
                        }
                    } else {
                        $closureUses[$alias] = $namespace;
                        $alias = null;
                    }
                    $state = null;
                    $namespace = null;
                } elseif ($state === T_USE && $token === ',') {
                    if ($alias === null) {
                        $closureUses[] = $namespace;
                    } else {
                        $closureUses[$alias] = $namespace;
                        $alias = null;
                    }
                    $namespace = null;
                }
            }
        }
        return [
            'namespace' => $closureNamespace,
            'uses' => $closureUses,
        ];
    }