예제 #1
0
 /**
  * Parses the update part of a for-statement.
  *
  * <code>
  *                                        -------------------------------
  * for ($x = 0, $y = 23, $z = 42; $x < $y; ++$x, $y = $x + 1, $z = $x + 2) {}
  *                                        -------------------------------
  * </code>
  *
  * @return PHP_Depend_Code_ASTForUpdate
  * @since 0.9.12
  */
 private function _parseForUpdate()
 {
     $this->_tokenStack->push();
     $this->_consumeComments();
     $update = null;
     if (($expr = $this->_parseOptionalExpression()) != null) {
         $update = $this->_builder->buildASTForUpdate();
         $update->addChild($expr);
         return $this->_setNodePositionsAndReturn($update);
     }
     $this->_tokenStack->pop();
     return null;
 }
예제 #2
0
파일: Parser.php 프로젝트: rouffj/pdepend
 /**
  * Parses a sequence of none php code tokens and returns the token type of
  * the next token.
  *
  * @return integer
  * @since 0.9.12
  */
 private function _parseNonePhpCode()
 {
     $this->consumeToken(self::T_CLOSE_TAG);
     $this->_tokenStack->push();
     while (($tokenType = $this->tokenizer->peek()) !== self::T_EOF) {
         switch ($tokenType) {
             case self::T_OPEN_TAG:
             case self::T_OPEN_TAG_WITH_ECHO:
                 $this->consumeToken($tokenType);
                 $tokenType = $this->tokenizer->peek();
                 break 2;
             default:
                 $this->consumeToken($tokenType);
                 break;
         }
     }
     $this->_tokenStack->pop();
     return $tokenType;
 }
예제 #3
0
 /**
  * testPopOnRootReturnsExpectedTokenArrayWithAllTokens
  *
  * @return void
  */
 public function testPopOnRootReturnsExpectedTokenArrayWithAllTokens()
 {
     $stack = new PHP_Depend_Parser_TokenStack();
     $stack->push();
     $expected = array($stack->add($this->createToken()), $stack->add($this->createToken()));
     $stack->push();
     $expected[] = $stack->add($this->createToken());
     $expected[] = $stack->add($this->createToken());
     $stack->pop();
     self::assertSame($expected, $stack->pop());
 }