/** * Parses the body of an switch label node. * * @param \PDepend\Source\AST\ASTSwitchLabel $label 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); }
/** * Tests the end column value. * * @param \PDepend\Source\AST\ASTSwitchLabel $label * * @return void * @depends testSwitchLabelDefault */ public function testSwitchLabelDefaultHasExpectedEndColumn($label) { $this->assertEquals(18, $label->getEndColumn()); }