/**
  * testSwitchStatementAlternativeScopeHasExpectedEndColumn
  *
  * @param \PDepend\Source\AST\ASTSwitchStatement $stmt
  *
  * @return void
  * @depends testSwitchStatementWithAlternativeScope
  */
 public function testSwitchStatementAlternativeScopeHasExpectedEndColumn($stmt)
 {
     $this->assertEquals(14, $stmt->getEndColumn());
 }
예제 #2
0
 /**
  * Parses the body of a switch statement.
  *
  * @param \PDepend\Source\AST\ASTSwitchStatement $switch The parent switch stmt.
  *
  * @return \PDepend\Source\AST\ASTSwitchStatement
  * @since  0.9.8
  */
 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;
         }
     }
     throw new UnexpectedTokenException($this->tokenizer->next(), $this->tokenizer->getSourceFile());
 }