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

parseSwitchLabelBody() private method

Parses the body of an switch label node.
private parseSwitchLabelBody ( PDepend\Source\AST\ASTSwitchLabel $label ) : PDepend\Source\AST\ASTSwitchLabel
$label PDepend\Source\AST\ASTSwitchLabel The context switch label.
return PDepend\Source\AST\ASTSwitchLabel
    private function parseSwitchLabelBody(\PDepend\Source\AST\ASTSwitchLabel $label)
    {
        $curlyBraceCount = 0;
        $tokenType = $this->tokenizer->peek();
        while ($tokenType !== Tokenizer::T_EOF) {
            switch ($tokenType) {
                case Tokens::T_CURLY_BRACE_OPEN:
                    $this->consumeToken(Tokens::T_CURLY_BRACE_OPEN);
                    ++$curlyBraceCount;
                    break;
                case Tokens::T_CURLY_BRACE_CLOSE:
                    if ($curlyBraceCount === 0) {
                        return $label;
                    }
                    $this->consumeToken(Tokens::T_CURLY_BRACE_CLOSE);
                    --$curlyBraceCount;
                    break;
                case Tokens::T_CLOSE_TAG:
                    $this->parseNonePhpCode();
                    break;
                case Tokens::T_CASE:
                case Tokens::T_DEFAULT:
                case Tokens::T_ENDSWITCH:
                    return $label;
                default:
                    $statement = $this->parseOptionalStatement();
                    if ($statement === null) {
                        $this->consumeToken($tokenType);
                    } elseif ($statement instanceof ASTNode) {
                        $label->addChild($statement);
                    }
                    // TODO: Change the <else if> into and <else> when the ast
                    //       implementation is finished.
                    break;
            }
            $tokenType = $this->tokenizer->peek();
        }
        throw new TokenStreamEndException($this->tokenizer);
    }
AbstractPHPParser