示例#1
0
 /**
  * @test
  */
 public function splitTokensFromPhpContents()
 {
     $lexer = new Stagehand_PHP_Lexer();
     $contents = file_get_contents(dirname(__FILE__) . '/LexerTest/example.php');
     $lexer->setContents($contents);
     $lexerToken = null;
     $parserToken = $lexer->yylex($lexerToken);
     $this->assertEquals($lexerToken->getValue(), '$foo');
     $this->assertEquals($lexerToken->getPosition(), 1);
     $this->assertEquals($parserToken, Stagehand_PHP_Parser::T_VARIABLE);
 }
示例#2
0
 /**
  * Parses PHP classes from text contents.
  *
  * @param string $contents  PHP script contents.
  * @return mixed
  */
 public static function parseContents($contents)
 {
     $lexer = new Stagehand_PHP_Lexer();
     $lexer->setContents($contents);
     return self::_parse($lexer);
 }