Linux unitednationsplay.com 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64
nginx/1.20.1
Server IP : 188.130.139.92 & Your IP : 18.116.62.169
Domains :
Cant Read [ /etc/named.conf ]
User : web
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
home /
www /
3 /
nikic /
php-parser /
test /
PhpParser /
Delete
Unzip
Name
Size
Permission
Date
Action
Builder
[ DIR ]
drwxr-xr-x
2018-10-10 09:00
ErrorHandler
[ DIR ]
drwxr-xr-x
2018-10-10 09:00
Internal
[ DIR ]
drwxr-xr-x
2018-10-10 09:00
Lexer
[ DIR ]
drwxr-xr-x
2018-10-10 09:00
Node
[ DIR ]
drwxr-xr-x
2018-10-10 09:00
NodeVisitor
[ DIR ]
drwxr-xr-x
2018-10-10 09:00
Parser
[ DIR ]
drwxr-xr-x
2018-10-10 09:00
BuilderFactoryTest.php
11.11
KB
-rw-r--r--
2018-10-10 09:00
CodeParsingTest.php
4
KB
-rw-r--r--
2018-10-10 09:00
CodeTestAbstract.php
1021
B
-rw-r--r--
2018-10-10 09:00
CodeTestParser.php
1.89
KB
-rw-r--r--
2018-10-10 09:00
CommentTest.php
1.76
KB
-rw-r--r--
2018-10-10 09:00
ConstExprEvaluatorTest.php
4.06
KB
-rw-r--r--
2018-10-10 09:00
ErrorTest.php
3.53
KB
-rw-r--r--
2018-10-10 09:00
JsonDecoderTest.php
1.28
KB
-rw-r--r--
2018-10-10 09:00
LexerTest.php
9.18
KB
-rw-r--r--
2018-10-10 09:00
NameContextTest.php
3.06
KB
-rw-r--r--
2018-10-10 09:00
NodeAbstractTest.php
9.84
KB
-rw-r--r--
2018-10-10 09:00
NodeDumperTest.php
2.41
KB
-rw-r--r--
2018-10-10 09:00
NodeFinderTest.php
2.32
KB
-rw-r--r--
2018-10-10 09:00
NodeTraverserTest.php
15.23
KB
-rw-r--r--
2018-10-10 09:00
ParserFactoryTest.php
1.06
KB
-rw-r--r--
2018-10-10 09:00
ParserTest.php
7.46
KB
-rw-r--r--
2018-10-10 09:00
PrettyPrinterTest.php
12.14
KB
-rw-r--r--
2018-10-10 09:00
Save
Rename
<?php declare(strict_types=1); namespace PhpParser; use PhpParser\Parser\Tokens; use PHPUnit\Framework\TestCase; class LexerTest extends TestCase { /* To allow overwriting in parent class */ protected function getLexer(array $options = []) { return new Lexer($options); } /** * @dataProvider provideTestError */ public function testError($code, $messages) { if (defined('HHVM_VERSION')) { $this->markTestSkipped('HHVM does not throw warnings from token_get_all()'); } $errorHandler = new ErrorHandler\Collecting(); $lexer = $this->getLexer(['usedAttributes' => [ 'comments', 'startLine', 'endLine', 'startFilePos', 'endFilePos' ]]); $lexer->startLexing($code, $errorHandler); $errors = $errorHandler->getErrors(); $this->assertCount(count($messages), $errors); for ($i = 0; $i < count($messages); $i++) { $this->assertSame($messages[$i], $errors[$i]->getMessageWithColumnInfo($code)); } } public function provideTestError() { return [ ["<?php /*", ["Unterminated comment from 1:7 to 1:9"]], ["<?php \1", ["Unexpected character \"\1\" (ASCII 1) from 1:7 to 1:7"]], ["<?php \0", ["Unexpected null byte from 1:7 to 1:7"]], // Error with potentially emulated token ["<?php ?? \0", ["Unexpected null byte from 1:10 to 1:10"]], ["<?php\n\0\1 foo /* bar", [ "Unexpected null byte from 2:1 to 2:1", "Unexpected character \"\1\" (ASCII 1) from 2:2 to 2:2", "Unterminated comment from 2:8 to 2:14" ]], ]; } /** * @dataProvider provideTestLex */ public function testLex($code, $options, $tokens) { $lexer = $this->getLexer($options); $lexer->startLexing($code); while ($id = $lexer->getNextToken($value, $startAttributes, $endAttributes)) { $token = array_shift($tokens); $this->assertSame($token[0], $id); $this->assertSame($token[1], $value); $this->assertEquals($token[2], $startAttributes); $this->assertEquals($token[3], $endAttributes); } } public function provideTestLex() { return [ // tests conversion of closing PHP tag and drop of whitespace and opening tags [ '<?php tokens ?>plaintext', [], [ [ Tokens::T_STRING, 'tokens', ['startLine' => 1], ['endLine' => 1] ], [ ord(';'), '?>', ['startLine' => 1], ['endLine' => 1] ], [ Tokens::T_INLINE_HTML, 'plaintext', ['startLine' => 1, 'hasLeadingNewline' => false], ['endLine' => 1] ], ] ], // tests line numbers [ '<?php' . "\n" . '$ token /** doc' . "\n" . 'comment */ $', [], [ [ ord('$'), '$', ['startLine' => 2], ['endLine' => 2] ], [ Tokens::T_STRING, 'token', ['startLine' => 2], ['endLine' => 2] ], [ ord('$'), '$', [ 'startLine' => 3, 'comments' => [ new Comment\Doc('/** doc' . "\n" . 'comment */', 2, 14, 5), ] ], ['endLine' => 3] ], ] ], // tests comment extraction [ '<?php /* comment */ // comment' . "\n" . '/** docComment 1 *//** docComment 2 */ token', [], [ [ Tokens::T_STRING, 'token', [ 'startLine' => 2, 'comments' => [ new Comment('/* comment */', 1, 6, 1), new Comment('// comment' . "\n", 1, 20, 3), new Comment\Doc('/** docComment 1 */', 2, 31, 4), new Comment\Doc('/** docComment 2 */', 2, 50, 5), ], ], ['endLine' => 2] ], ] ], // tests differing start and end line [ '<?php "foo' . "\n" . 'bar"', [], [ [ Tokens::T_CONSTANT_ENCAPSED_STRING, '"foo' . "\n" . 'bar"', ['startLine' => 1], ['endLine' => 2] ], ] ], // tests exact file offsets [ '<?php "a";' . "\n" . '// foo' . "\n" . '"b";', ['usedAttributes' => ['startFilePos', 'endFilePos']], [ [ Tokens::T_CONSTANT_ENCAPSED_STRING, '"a"', ['startFilePos' => 6], ['endFilePos' => 8] ], [ ord(';'), ';', ['startFilePos' => 9], ['endFilePos' => 9] ], [ Tokens::T_CONSTANT_ENCAPSED_STRING, '"b"', ['startFilePos' => 18], ['endFilePos' => 20] ], [ ord(';'), ';', ['startFilePos' => 21], ['endFilePos' => 21] ], ] ], // tests token offsets [ '<?php "a";' . "\n" . '// foo' . "\n" . '"b";', ['usedAttributes' => ['startTokenPos', 'endTokenPos']], [ [ Tokens::T_CONSTANT_ENCAPSED_STRING, '"a"', ['startTokenPos' => 1], ['endTokenPos' => 1] ], [ ord(';'), ';', ['startTokenPos' => 2], ['endTokenPos' => 2] ], [ Tokens::T_CONSTANT_ENCAPSED_STRING, '"b"', ['startTokenPos' => 5], ['endTokenPos' => 5] ], [ ord(';'), ';', ['startTokenPos' => 6], ['endTokenPos' => 6] ], ] ], // tests all attributes being disabled [ '<?php /* foo */ $bar;', ['usedAttributes' => []], [ [ Tokens::T_VARIABLE, '$bar', [], [] ], [ ord(';'), ';', [], [] ] ] ], // tests no tokens [ '', [], [] ], ]; } /** * @dataProvider provideTestHaltCompiler */ public function testHandleHaltCompiler($code, $remaining) { $lexer = $this->getLexer(); $lexer->startLexing($code); while (Tokens::T_HALT_COMPILER !== $lexer->getNextToken()); $this->assertSame($remaining, $lexer->handleHaltCompiler()); $this->assertSame(0, $lexer->getNextToken()); } public function provideTestHaltCompiler() { return [ ['<?php ... __halt_compiler();Remaining Text', 'Remaining Text'], ['<?php ... __halt_compiler ( ) ;Remaining Text', 'Remaining Text'], ['<?php ... __halt_compiler() ?>Remaining Text', 'Remaining Text'], //array('<?php ... __halt_compiler();' . "\0", "\0"), //array('<?php ... __halt_compiler /* */ ( ) ;Remaining Text', 'Remaining Text'), ]; } public function testHandleHaltCompilerError() { $this->expectException(Error::class); $this->expectExceptionMessage('__HALT_COMPILER must be followed by "();"'); $lexer = $this->getLexer(); $lexer->startLexing('<?php ... __halt_compiler invalid ();'); while (Tokens::T_HALT_COMPILER !== $lexer->getNextToken()); $lexer->handleHaltCompiler(); } public function testGetTokens() { $code = '<?php "a";' . "\n" . '// foo' . "\n" . '"b";'; $expectedTokens = [ [T_OPEN_TAG, '<?php ', 1], [T_CONSTANT_ENCAPSED_STRING, '"a"', 1], ';', [T_WHITESPACE, "\n", 1], [T_COMMENT, '// foo' . "\n", 2], [T_CONSTANT_ENCAPSED_STRING, '"b"', 3], ';', ]; $lexer = $this->getLexer(); $lexer->startLexing($code); $this->assertSame($expectedTokens, $lexer->getTokens()); } }