Exemple #1
0
 /**
  * Parses the body of an switch label node.
  *
  * @param PHP_Depend_Code_ASTSwitchLabel $label The context switch label.
  *
  * @return PHP_Depend_Code_ASTSwitchLabel
  */
 private function _parseSwitchLabelBody(PHP_Depend_Code_ASTSwitchLabel $label)
 {
     $curlyBraceCount = 0;
     $tokenType = $this->tokenizer->peek();
     while ($tokenType !== self::T_EOF) {
         switch ($tokenType) {
             case self::T_CURLY_BRACE_OPEN:
                 $this->consumeToken(self::T_CURLY_BRACE_OPEN);
                 ++$curlyBraceCount;
                 break;
             case self::T_CURLY_BRACE_CLOSE:
                 if ($curlyBraceCount === 0) {
                     return $label;
                 }
                 $this->consumeToken(self::T_CURLY_BRACE_CLOSE);
                 --$curlyBraceCount;
                 break;
             case self::T_CASE:
             case self::T_DEFAULT:
             case self::T_ENDSWITCH:
                 return $label;
             default:
                 $statement = $this->_parseOptionalStatement();
                 if ($statement === null) {
                     $this->consumeToken($tokenType);
                 } else {
                     if ($statement instanceof PHP_Depend_Code_ASTNodeI) {
                         $label->addChild($statement);
                     }
                 }
                 // TODO: Change the <else if> into and <else> when the ast
                 //       implementation is finished.
                 break;
         }
         $tokenType = $this->tokenizer->peek();
     }
     throw new PHP_Depend_Parser_TokenStreamEndException($this->tokenizer);
 }
Exemple #2
0
 /**
  * testMagicSleepReturnsExpectedSetOfPropertyNames
  *
  * @return void
  * @group pdepend
  * @group pdepend::ast
  * @group unittest
  */
 public function testMagicSleepReturnsExpectedSetOfPropertyNames()
 {
     $label = new PHP_Depend_Code_ASTSwitchLabel();
     self::assertEquals(array('default', 'image', 'comment', 'startLine', 'startColumn', 'endLine', 'endColumn', 'nodes'), $label->__sleep());
 }
 /**
  * Tests the end column value.
  *
  * @param PHP_Depend_Code_ASTSwitchLabel $label
  *
  * @return void
  * @depends testSwitchLabelDefault
  */
 public function testSwitchLabelDefaultHasExpectedEndColumn($label)
 {
     $this->assertEquals(18, $label->getEndColumn());
 }