getNextToken() public méthode

public getNextToken ( &$value = null, &$startAttributes = null, &$endAttributes = null )
 /**
  * @dataProvider provideTestLexNewFeatures
  */
 public function testLeaveStuffAloneInStrings($code)
 {
     $stringifiedToken = '"' . addcslashes($code, '"\\') . '"';
     $this->lexer->startLexing('<?php ' . $stringifiedToken);
     $this->assertEquals(Parser::T_CONSTANT_ENCAPSED_STRING, $this->lexer->getNextToken($text));
     $this->assertEquals($stringifiedToken, $text);
     $this->assertEquals(0, $this->lexer->getNextToken());
 }
Exemple #2
0
 public function getNextToken(&$value = NULL, &$startAttributes = NULL, &$endAttributes = NULL)
 {
     $tokenId = parent::getNextToken($value, $startAttributes, $endAttributes);
     if ($tokenId == Tokens::T_CONSTANT_ENCAPSED_STRING || $tokenId == Tokens::T_LNUMBER || $tokenId == Tokens::T_DNUMBER) {
         $endAttributes['originalValue'] = $value;
     }
     return $tokenId;
 }
 public function getNextToken(&$value = null, &$startAttributes = null, &$endAttributes = null)
 {
     $tokenId = parent::getNextToken($value, $startAttributes, $endAttributes);
     if ($tokenId == Parser::T_CONSTANT_ENCAPSED_STRING || $tokenId == Parser::T_LNUMBER || $tokenId == Parser::T_DNUMBER) {
         // could also use $startAttributes, doesn't really matter here
         $endAttributes['originalValue'] = $value;
     }
     return $tokenId;
 }
Exemple #4
0
 public function getNextToken(&$value = null, &$startAttributes = null, &$endAttributes = null)
 {
     $tokenId = parent::getNextToken($value, $startAttributes, $endAttributes);
     if ($tokenId == Tokens::T_ARRAY) {
         $startAttributes['traditionalArray'] = true;
     }
     if ($tokenId == Tokens::T_EXIT) {
         $startAttributes['isDie'] = strtolower($value) === 'die';
     }
     if ($tokenId == Tokens::T_CONSTANT_ENCAPSED_STRING) {
         $endAttributes['originalValue'] = $value;
     }
     return $tokenId;
 }
 /**
  * Override to the native getNextToken method
  *
  * This method override ensures that the original value of tokens that would be transformed is stored
  * besides them in the result ast. Depending on the token type various attributes will be added to the token
  * and produced ast. These modifications are required to ensure the correct behaviour of the binary number
  * detection, the detection of booth flavors of the doc syntax, short array syntax and short echo tags.
  *
  * @param null|string $value Value of the token
  * @param null|array $startAttributes
  * @param null|array $endAttributes
  * @return int Retrieved token id
  * @see https://github.com/nikic/PHP-Parser/issues/26#issuecomment-6150035 Original implementation
  */
 public function getNextToken(&$value = null, &$startAttributes = null, &$endAttributes = null)
 {
     $tokenId = parent::getNextToken($value, $startAttributes, $endAttributes);
     if ($tokenId === Tokens::T_LNUMBER || $tokenId === Tokens::T_DNUMBER) {
         // could also use $startAttributes, doesn't really matter here
         $endAttributes['originalValue'] = $value;
     } elseif ($tokenId === Tokens::T_START_HEREDOC) {
         $startAttributes['isDocSyntax'] = true;
         if (substr($this->code, $startAttributes['startFilePos'] + 3, 1) === '\'') {
             $startAttributes['isNowDoc'] = true;
         } else {
             $startAttributes['isHereDoc'] = true;
         }
     } elseif ($tokenId === Tokens::T_ARRAY) {
         $startAttributes['traditionalArray'] = true;
     } elseif ($tokenId === Tokens::T_ECHO) {
         if (substr($this->code, $startAttributes['startFilePos'], 3) === '<?=') {
             $startAttributes['isShortEchoTag'] = true;
         }
     }
     return $tokenId;
 }