public function beforeTraverse(array $nodes)
    {
        if (empty($nodes)) {
            return $nodes;
        }

        $last = \end($nodes);

        if ($last instanceof Namespace_) {
            $kind = $last->getAttribute('kind');

            // Treat all namespace statements pre-PHP-Parser v3.1.2 as "open",
            // even though we really have no way of knowing.
            if ($kind === null || $kind === Namespace_::KIND_SEMICOLON) {
                // Save the current namespace for open namespaces
                $this->setNamespace($last->name);
            } else {
                // Clear the current namespace after a braced namespace
                $this->setNamespace(null);
            }

            return $nodes;
        }

        return $this->namespace ? [new Namespace_($this->namespace, $nodes)] : $nodes;
    }
public function beforeTraverse(array $nodes)
    {
        if (empty($nodes)) {
            return $nodes;
        }

        $last = \end($nodes);

        if ($last instanceof Namespace_) {
            $kind = $last->getAttribute('kind');

            // Treat all namespace statements pre-PHP-Parser v3.1.2 as "open",
            // even though we really have no way of knowing.
            if ($kind === null || $kind === Namespace_::KIND_SEMICOLON) {
                // Save the current namespace for open namespaces
                $this->setNamespace($last->name);
            } else {
                // Clear the current namespace after a braced namespace
                $this->setNamespace(null);
            }

            return $nodes;
        }

        return $this->namespace ? [new Namespace_($this->namespace, $nodes)] : $nodes;
    }
public function beforeTraverse ( array $ nodes ) { if ( empty ( $ nodes ) ) { return $ nodes ; } $ last = \ end ( $ nodes ) ; if ( $ last instanceof Namespace_ ) { $ kind = $ last -> getAttribute ( 'kind' ) ; // Treat all namespace statements pre-PHP-Parser v3.1.2 as "open", // even though we really have no way of knowing. if ( $ kind === null || $ kind === Namespace_ :: KIND_SEMICOLON ) { // Save the current namespace for open namespaces $ this -> setNamespace ( $ last -> name ) ; } else { // Clear the current namespace after a braced namespace $ this -> setNamespace ( null ) ; } return $ nodes ; } return $ this -> namespace ? [ new Namespace_ ( $ this -> namespace , $ nodes ) ] : $ nodes ; }
If this is a standalone namespace line, remember it for later.

Otherwise, apply remembered namespaces to the code until a new namespace
is encountered.

@param array $nodes
If this is a standalone namespace line remember it for later .