Beispiel #1
0
 /**
  * testAcceptReturnsReturnValueOfVisitMethod
  *
  * @return void
  * @covers PHP_Depend_Code_ASTNode
  * @covers PHP_Depend_Code_ASTSwitchStatement
  * @group pdepend
  * @group pdepend::ast
  * @group unittest
  */
 public function testAcceptReturnsReturnValueOfVisitMethod()
 {
     $visitor = $this->getMock('PHP_Depend_Code_ASTVisitorI');
     $visitor->expects($this->once())->method('__call')->with($this->equalTo('visitSwitchStatement'))->will($this->returnValue(42));
     $stmt = new PHP_Depend_Code_ASTSwitchStatement();
     self::assertEquals(42, $stmt->accept($visitor));
 }
Beispiel #2
0
 /**
  * Parses the body of a switch statement.
  *
  * @param PHP_Depend_Code_ASTSwitchStatement $switch The parent switch stmt.
  *
  * @return PHP_Depend_Code_ASTSwitchStatement
  * @since 0.9.8
  */
 private function _parseSwitchStatementBody(PHP_Depend_Code_ASTSwitchStatement $switch)
 {
     $this->consumeComments();
     if ($this->tokenizer->peek() === self::T_CURLY_BRACE_OPEN) {
         $this->consumeToken(self::T_CURLY_BRACE_OPEN);
     } else {
         $this->consumeToken(self::T_COLON);
     }
     while (($tokenType = $this->tokenizer->peek()) !== self::T_EOF) {
         switch ($tokenType) {
             case self::T_ENDSWITCH:
                 $this->_parseAlternativeScopeTermination(self::T_ENDSWITCH);
                 return $switch;
             case self::T_CURLY_BRACE_CLOSE:
                 $this->consumeToken(self::T_CURLY_BRACE_CLOSE);
                 return $switch;
             case self::T_CASE:
                 $switch->addChild($this->_parseSwitchLabel());
                 break;
             case self::T_DEFAULT:
                 $switch->addChild($this->_parseSwitchLabelDefault());
                 break;
             case self::T_COMMENT:
             case self::T_DOC_COMMENT:
                 $this->consumeToken($tokenType);
                 break;
             default:
                 break 2;
         }
     }
     throw new PHP_Depend_Parser_UnexpectedTokenException($this->tokenizer->next(), $this->tokenizer->getSourceFile());
 }
 /**
  * testSwitchStatementAlternativeScopeHasExpectedEndColumn
  *
  * @param PHP_Depend_Code_ASTSwitchStatement $stmt
  *
  * @return void
  * @depends testSwitchStatementWithAlternativeScope
  */
 public function testSwitchStatementAlternativeScopeHasExpectedEndColumn($stmt)
 {
     $this->assertEquals(14, $stmt->getEndColumn());
 }