PDepend\Source\Language\PHP\PHPParserVersion70::parseAnonymousClassDeclaration PHP Method

parseAnonymousClassDeclaration() protected method

Attempts to the next sequence of tokens as an anonymous class and adds it to the allocation expression
protected parseAnonymousClassDeclaration ( PDepend\Source\AST\ASTAllocationExpression $allocation ) : null | ASTAnonymousClass
$allocation PDepend\Source\AST\ASTAllocationExpression
return null | PDepend\Source\AST\ASTAnonymousClass
    protected function parseAnonymousClassDeclaration(ASTAllocationExpression $allocation)
    {
        $this->consumeComments();
        switch ($this->tokenizer->peek()) {
            case Tokens::T_CLASS:
                $this->tokenStack->push();
                $this->consumeToken(Tokens::T_CLASS);
                $this->consumeComments();
                $class = $this->builder->buildAnonymousClass();
                $class->setName(sprintf('class@anonymous%s0x%s', $this->compilationUnit->getFileName(), uniqid('')));
                $class->setCompilationUnit($this->compilationUnit);
                $class->setUserDefined();
                if ($this->isNextTokenArguments()) {
                    $class->addChild($this->parseArguments());
                }
                $this->consumeComments();
                $tokenType = $this->tokenizer->peek();
                if ($tokenType === Tokens::T_EXTENDS) {
                    $class = $this->parseClassExtends($class);
                    $this->consumeComments();
                    $tokenType = $this->tokenizer->peek();
                }
                if ($tokenType === Tokens::T_IMPLEMENTS) {
                    $this->consumeToken(Tokens::T_IMPLEMENTS);
                    $this->parseInterfaceList($class);
                }
                $allocation->addChild($this->setNodePositionsAndReturn($this->parseTypeBody($class), $tokens));
                $class->setTokens($tokens);
                return $allocation;
        }
        return null;
    }