PhpParser\Lexer\Emulative::startLexing PHP Method

startLexing() public method

public startLexing ( $code, PhpParser\ErrorHandler $errorHandler = null )
$errorHandler PhpParser\ErrorHandler
    public function startLexing($code, ErrorHandler $errorHandler = null)
    {
        $this->inObjectAccess = false;
        parent::startLexing($code, $errorHandler);
        if ($this->requiresEmulation($code)) {
            $this->emulateTokens();
        }
    }

Usage Example

Example #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());
 }