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

parseSwitchStatementBody() private method

Parses the body of a switch statement.
Since: 0.9.8
private parseSwitchStatementBody ( PDepend\Source\AST\ASTSwitchStatement $switch ) : PDepend\Source\AST\ASTSwitchStatement
$switch PDepend\Source\AST\ASTSwitchStatement The parent switch stmt.
return PDepend\Source\AST\ASTSwitchStatement
    private function parseSwitchStatementBody(ASTSwitchStatement $switch)
    {
        $this->consumeComments();
        if ($this->tokenizer->peek() === Tokens::T_CURLY_BRACE_OPEN) {
            $this->consumeToken(Tokens::T_CURLY_BRACE_OPEN);
        } else {
            $this->consumeToken(Tokens::T_COLON);
        }
        while (($tokenType = $this->tokenizer->peek()) !== Tokenizer::T_EOF) {
            switch ($tokenType) {
                case Tokens::T_CLOSE_TAG:
                    $this->parseNonePhpCode();
                    break;
                case Tokens::T_ENDSWITCH:
                    $this->parseAlternativeScopeTermination(Tokens::T_ENDSWITCH);
                    return $switch;
                case Tokens::T_CURLY_BRACE_CLOSE:
                    $this->consumeToken(Tokens::T_CURLY_BRACE_CLOSE);
                    return $switch;
                case Tokens::T_CASE:
                    $switch->addChild($this->parseSwitchLabel());
                    break;
                case Tokens::T_DEFAULT:
                    $switch->addChild($this->parseSwitchLabelDefault());
                    break;
                case Tokens::T_COMMENT:
                case Tokens::T_DOC_COMMENT:
                    $this->consumeToken($tokenType);
                    break;
                default:
                    break 2;
            }
        }
        $this->throwUnexpectedTokenException();
    }
AbstractPHPParser