PhpParser\Lexer\Emulative::getNextToken PHP Method

getNextToken() public method

public getNextToken ( &$value = null, &$startAttributes = null, &$endAttributes = null )
    public function getNextToken(&$value = null, &$startAttributes = null, &$endAttributes = null)
    {
        $token = parent::getNextToken($value, $startAttributes, $endAttributes);
        // replace new keywords by their respective tokens. This is not done
        // if we currently are in an object access (e.g. in $obj->namespace
        // "namespace" stays a T_STRING tokens and isn't converted to T_NAMESPACE)
        if (Tokens::T_STRING === $token && !$this->inObjectAccess) {
            if (isset($this->newKeywords[strtolower($value)])) {
                return $this->newKeywords[strtolower($value)];
            }
        } else {
            // keep track of whether we currently are in an object access (after ->)
            $this->inObjectAccess = Tokens::T_OBJECT_OPERATOR === $token;
        }
        return $token;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * @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());
 }
All Usage Examples Of PhpParser\Lexer\Emulative::getNextToken