PDepend\Source\Language\PHP\AbstractPHPParser::parseNamespaceDeclaration PHP Method

parseNamespaceDeclaration() private method

This method parses a PHP 5.3 namespace declaration.
Since: 0.9.5
private parseNamespaceDeclaration ( ) : void
return void
    private function parseNamespaceDeclaration()
    {
        // Consume namespace keyword and strip optional comments
        $this->consumeToken(Tokens::T_NAMESPACE);
        $this->consumeComments();
        $tokenType = $this->tokenizer->peek();
        // Search for a namespace identifier
        if ($this->isClassName($tokenType)) {
            // Reset namespace property
            $this->namespaceName = null;
            $qualifiedName = $this->parseQualifiedName();
            $this->consumeComments();
            if ($this->tokenizer->peek() === Tokens::T_CURLY_BRACE_OPEN) {
                $this->consumeToken(Tokens::T_CURLY_BRACE_OPEN);
            } else {
                $this->consumeToken(Tokens::T_SEMICOLON);
            }
            // Create a package for this namespace
            $this->namespaceName = $qualifiedName;
            $this->useSymbolTable->resetScope();
        } elseif ($tokenType === Tokens::T_BACKSLASH) {
            // Same namespace reference, something like:
            //   new namespace\Foo();
            // or:
            //   $x = namespace\foo::bar();
            // Now parse a qualified name
            $this->parseQualifiedNameRaw();
        } else {
            // Consume opening curly brace
            $this->consumeToken(Tokens::T_CURLY_BRACE_OPEN);
            // Create a package for this namespace
            $this->namespaceName = '';
            $this->useSymbolTable->resetScope();
        }
        $this->reset();
    }
AbstractPHPParser