Server IP : 127.0.0.2 / Your IP : 3.14.4.171 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/vendor/nikic/php-parser/test/PhpParser/Lexer/ |
Upload File : |
<?php namespace PhpParser\Lexer; use PhpParser\LexerTest; use PhpParser\Parser\Tokens; require_once __DIR__ . '/../LexerTest.php'; class EmulativeTest extends LexerTest { protected function getLexer(array $options = array()) { return new Emulative($options); } /** * @dataProvider provideTestReplaceKeywords */ public function testReplaceKeywords($keyword, $expectedToken) { $lexer = $this->getLexer(); $lexer->startLexing('<?php ' . $keyword); $this->assertSame($expectedToken, $lexer->getNextToken()); $this->assertSame(0, $lexer->getNextToken()); } /** * @dataProvider provideTestReplaceKeywords */ public function testNoReplaceKeywordsAfterObjectOperator($keyword) { $lexer = $this->getLexer(); $lexer->startLexing('<?php ->' . $keyword); $this->assertSame(Tokens::T_OBJECT_OPERATOR, $lexer->getNextToken()); $this->assertSame(Tokens::T_STRING, $lexer->getNextToken()); $this->assertSame(0, $lexer->getNextToken()); } public function provideTestReplaceKeywords() { return array( // PHP 5.5 array('finally', Tokens::T_FINALLY), array('yield', Tokens::T_YIELD), // PHP 5.4 array('callable', Tokens::T_CALLABLE), array('insteadof', Tokens::T_INSTEADOF), array('trait', Tokens::T_TRAIT), array('__TRAIT__', Tokens::T_TRAIT_C), // PHP 5.3 array('__DIR__', Tokens::T_DIR), array('goto', Tokens::T_GOTO), array('namespace', Tokens::T_NAMESPACE), array('__NAMESPACE__', Tokens::T_NS_C), ); } /** * @dataProvider provideTestLexNewFeatures */ public function testLexNewFeatures($code, array $expectedTokens) { $lexer = $this->getLexer(); $lexer->startLexing('<?php ' . $code); foreach ($expectedTokens as $expectedToken) { list($expectedTokenType, $expectedTokenText) = $expectedToken; $this->assertSame($expectedTokenType, $lexer->getNextToken($text)); $this->assertSame($expectedTokenText, $text); } $this->assertSame(0, $lexer->getNextToken()); } /** * @dataProvider provideTestLexNewFeatures */ public function testLeaveStuffAloneInStrings($code) { $stringifiedToken = '"' . addcslashes($code, '"\\') . '"'; $lexer = $this->getLexer(); $lexer->startLexing('<?php ' . $stringifiedToken); $this->assertSame(Tokens::T_CONSTANT_ENCAPSED_STRING, $lexer->getNextToken($text)); $this->assertSame($stringifiedToken, $text); $this->assertSame(0, $lexer->getNextToken()); } public function provideTestLexNewFeatures() { return array( array('yield from', array( array(Tokens::T_YIELD_FROM, 'yield from'), )), array("yield\r\nfrom", array( array(Tokens::T_YIELD_FROM, "yield\r\nfrom"), )), array('...', array( array(Tokens::T_ELLIPSIS, '...'), )), array('**', array( array(Tokens::T_POW, '**'), )), array('**=', array( array(Tokens::T_POW_EQUAL, '**='), )), array('??', array( array(Tokens::T_COALESCE, '??'), )), array('<=>', array( array(Tokens::T_SPACESHIP, '<=>'), )), array('0b1010110', array( array(Tokens::T_LNUMBER, '0b1010110'), )), array('0b1011010101001010110101010010101011010101010101101011001110111100', array( array(Tokens::T_DNUMBER, '0b1011010101001010110101010010101011010101010101101011001110111100'), )), array('\\', array( array(Tokens::T_NS_SEPARATOR, '\\'), )), array("<<<'NOWDOC'\nNOWDOC;\n", array( array(Tokens::T_START_HEREDOC, "<<<'NOWDOC'\n"), array(Tokens::T_END_HEREDOC, 'NOWDOC'), array(ord(';'), ';'), )), array("<<<'NOWDOC'\nFoobar\nNOWDOC;\n", array( array(Tokens::T_START_HEREDOC, "<<<'NOWDOC'\n"), array(Tokens::T_ENCAPSED_AND_WHITESPACE, "Foobar\n"), array(Tokens::T_END_HEREDOC, 'NOWDOC'), array(ord(';'), ';'), )), ); } }