public function leaveNode(Node $node)
    {
        if ($node instanceof Use_) {
            // Store a reference to every "use" statement, because we'll need
            // them in a bit.
            foreach ($node->uses as $use) {
                $alias = $use->alias ?: \end($use->name->parts);
                $this->aliases[\strtolower($alias)] = $use->name;
            }

            return NodeTraverser::REMOVE_NODE;
        } elseif ($node instanceof GroupUse) {
            // Expand every "use" statement in the group into a full, standalone
            // "use" and store 'em with the others.
            foreach ($node->uses as $use) {
                $alias = $use->alias ?: \end($use->name->parts);
                $this->aliases[\strtolower($alias)] = Name::concat($node->prefix, $use->name, [
                    'startLine' => $node->prefix->getAttribute('startLine'),
                    'endLine'   => $use->name->getAttribute('endLine'),
                ]);
            }

            return NodeTraverser::REMOVE_NODE;
        } elseif ($node instanceof Namespace_) {
            // Start fresh, since we're done with this namespace.
            $this->lastNamespace = $node->name;
            $this->lastAliases   = $this->aliases;
            $this->aliases       = [];
        } else {
            foreach ($node as $name => $subNode) {
                if ($subNode instanceof Name) {
                    // Implicitly thunk all aliases.
                    if ($replacement = $this->findAlias($subNode)) {
                        $node->$name = $replacement;
                    }
                }
            }

            return $node;
        }
    }
public function leaveNode(Node $node)
    {
        if ($node instanceof Use_) {
            // Store a reference to every "use" statement, because we'll need
            // them in a bit.
            foreach ($node->uses as $use) {
                $alias = $use->alias ?: \end($use->name->parts);
                $this->aliases[\strtolower($alias)] = $use->name;
            }

            return NodeTraverser::REMOVE_NODE;
        } elseif ($node instanceof GroupUse) {
            // Expand every "use" statement in the group into a full, standalone
            // "use" and store 'em with the others.
            foreach ($node->uses as $use) {
                $alias = $use->alias ?: \end($use->name->parts);
                $this->aliases[\strtolower($alias)] = Name::concat($node->prefix, $use->name, [
                    'startLine' => $node->prefix->getAttribute('startLine'),
                    'endLine'   => $use->name->getAttribute('endLine'),
                ]);
            }

            return NodeTraverser::REMOVE_NODE;
        } elseif ($node instanceof Namespace_) {
            // Start fresh, since we're done with this namespace.
            $this->lastNamespace = $node->name;
            $this->lastAliases   = $this->aliases;
            $this->aliases       = [];
        } else {
            foreach ($node as $name => $subNode) {
                if ($subNode instanceof Name) {
                    // Implicitly thunk all aliases.
                    if ($replacement = $this->findAlias($subNode)) {
                        $node->$name = $replacement;
                    }
                }
            }

            return $node;
        }
    }
public function leaveNode ( Node $ node ) { if ( $ node instanceof Use_ ) { // Store a reference to every "use" statement, because we'll need // them in a bit. foreach ( $ node -> uses as $ use ) { $ alias = $ use -> alias ? : \ end ( $ use -> name -> parts ) ; $ this -> aliases [ \ strtolower ( $ alias ) ] = $ use -> name ; } return NodeTraverser :: REMOVE_NODE ; } elseif ( $ node instanceof GroupUse ) { // Expand every "use" statement in the group into a full, standalone // "use" and store 'em with the others. foreach ( $ node -> uses as $ use ) { $ alias = $ use -> alias ? : \ end ( $ use -> name -> parts ) ; $ this -> aliases [ \ strtolower ( $ alias ) ] = Name :: concat ( $ node -> prefix , $ use -> name , [ 'startLine' => $ node -> prefix -> getAttribute ( 'startLine' ) , 'endLine' => $ use -> name -> getAttribute ( 'endLine' ) , ] ) ; } return NodeTraverser :: REMOVE_NODE ; } elseif ( $ node instanceof Namespace_ ) { // Start fresh, since we're done with this namespace. $ this -> lastNamespace = $ node -> name ; $ this -> lastAliases = $ this -> aliases ; $ this -> aliases = [ ] ; } else { foreach ( $ node as $ name => $ subNode ) { if ( $ subNode instanceof Name ) { // Implicitly thunk all aliases. if ( $ replacement = $ this -> findAlias ( $ subNode ) ) { $ node -> $ name = $ replacement ; } } } return $ node ; } }
If this statement is a namespace, forget all the aliases we had.

If it's a use statement, remember the alias for later. Otherwise, apply
remembered aliases to the code.

@param Node $node
If this statement is a namespace forget all the aliases we had .