How to use getNamespace method of parser class

Best Atoum code snippet using parser.getNamespace

PHPFileParserTest.php

Source:PHPFileParserTest.php Github

copy

Full Screen

...24 {25 $mockSplFileInfo = $this->createFileMock('');26 $parser = $this->initializeParser($mockSplFileInfo);27 $parser->parse();28 $this->assertSame(null, $parser->getNamespace());29 $this->assertSame([], $parser->getCalls());30 $this->assertSame([], $parser->getNamespaces());31 }32 /**33 * @test34 */35 public function parse_complexExample_caseInsensitive()36 {37 $mockSplFileInfo = $this->createFileMock('<?php38 use my\\aliasnamespace as aliasNamespace /*comment*/;39 use my\\test2\\example2 as /*comment*/ aliasClass;40 use my\\test2\\myexception /*comment*/ as aliasException;41 function myFunction1(){42 $var1 = new example1();43 $var2 = new \\my\\test2\\Example1();44 $var3 = new aliasNamespace\\Example1/*comment*/();45 $var4 = new /*comment*/aliasClass();46 $var5 = Example1::class;47 $var6 = \\my\\test2\\Example1::class;48 $var7 = aliasNamespace\\Example1::class;49 $var8 = /*comment*/aliasClass::class;50 try{}catch(Exception $e){}51 try{}catch(MyException $e){}52 try{}catch(\\my\\test2\\MyException $e){}53 try{}catch(aliasNamespace\\MyException /*comment*/ $e){}54 try{}catch(/*comment*/ aliasexception $e){}55 //$comment = new CommentedCall();56 //$comment2 = new \\my\\test2\\CommentedCall();57 //$comment3 = new aliasNamespace\\CommentedCall();58 //$comment4 = new aliasClass();59 /**60 $comment = new CommentedCall();61 $comment2 = new \\my\\test2\\CommentedCall();62 $comment3 = new aliasNamespace\\CommentedCall();63 $comment4 = new aliasClass();64 */65 }66 class TestExample extends Example1{}67 class TestExample2 extends \\my\\test2\\Example1{}68 class TestExample3 extends aliasNamespace\\Example1{}69 class TestExample4 extends /*comment*/ aliasClass{70 public function myFunction1(array/*test*/ $arg1, Example1 $arg2 //comment171 , \\my\\test2\\Example1 $arg3 = null //comment272 , aliasNamespace\\Example1 $arg473 , aliasClass $arg5){74 }75 }76 class TestExample5 implements /*comment*/ myInterface{}77 78 if($test instanceof Example1){79 }else if($test instanceof \\my\\test2\\Example1){80 }else if($test instanceof aliasNamespace\\Example1){81 }else if($test instanceof /*comment*/ aliasClass){82 }83 ');84 $parser = $this->initializeParser($mockSplFileInfo);85 $parser->parse();86 $this->assertSame(null, $parser->getNamespace());87 $this->assertSame(['example1'88 , 'my\\test2\\Example1'89 , 'my\\aliasnamespace\\Example1'90 , 'my\\test2\\example2'91 , 'Example1'92 , 'my\\test2\\Example1'93 , 'my\\aliasnamespace\\Example1'94 , 'my\\test2\\example2'95 , 'Exception'96 , 'MyException'97 , 'my\\test2\\MyException'98 , 'my\\aliasnamespace\\MyException'99 , 'my\\test2\\myexception'100 , 'Example1'101 , 'my\\test2\\Example1'102 , 'my\\aliasnamespace\\Example1'103 , 'my\\test2\\example2'104 , 'Example1'105 , 'my\\test2\\Example1'106 , 'my\\aliasnamespace\\Example1'107 , 'my\\test2\\example2'108 ,'myInterface'109 , 'Example1'110 , 'my\\test2\\Example1'111 , 'my\\aliasnamespace\\Example1'112 , 'my\\test2\\example2'], $parser->getCalls());113 $this->assertSame(['example1'114 ,'my\\test2\Example1'115 ,'my\\aliasnamespace\\Example1'116 ,'my\\test2\\example2'117 ,'Exception'118 ,'MyException'119 ,'my\\test2\\MyException'120 ,'my\\aliasnamespace\\MyException'121 ,'myInterface'],$parser->getAllUsedNamespaces());122 $this->assertSame([['use' => 'my\\aliasnamespace', 'alias' => 'aliasNamespace']123 , ['use' => 'my\\test2\\example2', 'alias' => 'aliasClass']124 , ['use' => 'my\\test2\\myexception', 'alias' => 'aliasException']], $parser->getNamespaces());125 }126 /**127 * @test128 */129 public function parse_complexExample()130 {131 $mockSplFileInfo = $this->createFileMock('<?php132 use my\\aliasNamespace as aliasNamespace;133 use my\\test2\\Example2 as aliasClass;134 use my\\test2\\MyException as aliasException;135 function myFunction1(){136 $var1 = new Example1();137 $var2 = new \\my\\test2\\Example1();138 $var3 = new aliasNamespace\\Example1();139 $var4 = new aliasClass();140 $var5 = Example1::class;141 $var6 = \\my\\test2\\Example1::class;142 $var7 = aliasNamespace\\Example1::class;143 $var8 = aliasClass::class;144 try{}catch(Exception $e){}145 try{}catch(MyException $e){}146 try{}catch(\\my\\test2\\MyException $e){}147 try{}catch(aliasNamespace\\MyException $e){}148 try{}catch(aliasException $e){}149 //$comment = new CommentedCall();150 //$comment2 = new \\my\\test2\\CommentedCall();151 //$comment3 = new aliasNamespace\\CommentedCall();152 //$comment4 = new aliasClass();153 /**154 $comment = new CommentedCall();155 $comment2 = new \\my\\test2\\CommentedCall();156 $comment3 = new aliasNamespace\\CommentedCall();157 $comment4 = new aliasClass();158 */159 }160 class TestExample extends Example1{}161 class TestExample2 extends \\my\\test2\\Example1{}162 class TestExample3 extends aliasNamespace\\Example1{}163 class TestExample4 extends aliasClass{164 public function myFunction1(array $arg1, Example1 $arg2165 , \\my\\test2\\Example1 $arg3 = null166 , aliasNamespace\\Example1 $arg4167 , aliasClass $arg5){168 throw new \\LogicException();169 }170 }171 ');172 $parser = $this->initializeParser($mockSplFileInfo);173 $parser->parse();174 $this->assertSame(null, $parser->getNamespace());175 $this->assertSame(['Example1'176 , 'my\\test2\\Example1'177 , 'my\\aliasNamespace\\Example1'178 , 'my\\test2\\Example2'179 , 'Example1'180 , 'my\\test2\\Example1'181 , 'my\\aliasNamespace\\Example1'182 , 'my\\test2\\Example2'183 , 'Exception'184 , 'MyException'185 , 'my\\test2\\MyException'186 , 'my\\aliasNamespace\\MyException'187 , 'my\\test2\\MyException'188 , 'Example1'189 , 'my\\test2\\Example1'190 , 'my\\aliasNamespace\\Example1'191 , 'my\\test2\\Example2'192 , 'Example1'193 , 'my\\test2\\Example1'194 , 'my\\aliasNamespace\\Example1'195 , 'my\\test2\\Example2'196 ,'LogicException'], $parser->getCalls());197 $this->assertSame([['use' => 'my\\aliasNamespace', 'alias' => 'aliasNamespace']198 , ['use' => 'my\\test2\\Example2', 'alias' => 'aliasClass']199 , ['use' => 'my\\test2\\MyException', 'alias' => 'aliasException']], $parser->getNamespaces());200 }201 /**202 * @test203 */204 public function parse_complexExample_withNamespace()205 {206 $mockSplFileInfo = $this->createFileMock('<?php207 namespace my\\test;208 use my\\aliasNamespace as aliasNamespace;209 use my\\test2\\Example2 as aliasClass;210 use my\\test2\\MyException as aliasException;211 function myFunction1(){212 $var1 = new Example1();213 $var2 = new my\\test2\\Example1();214 $var3 = new aliasNamespace\\Example1();215 $var4 = new aliasClass();216 $var5 = Example1::class;217 $var6 = my\\test2\\Example1::class;218 $var7 = aliasNamespace\\Example1::class;219 $var8 = aliasClass::class;220 try{}catch( Exception $e){}221 try{}catch(MyException $e){}222 try{}catch(my\\test2\\MyException $e){}223 try{}catch(aliasNamespace\\MyException $e){}224 try{}catch(aliasException $e){}225 //$comment = new CommentedCall();226 //$comment2 = new my\\test2\\CommentedCall();227 //$comment3 = new aliasNamespace\\CommentedCall();228 //$comment4 = new aliasClass();229 /**230 $comment = new CommentedCall();231 $comment2 = new my\\test2\\CommentedCall();232 $comment3 = new aliasNamespace\\CommentedCall();233 $comment4 = new aliasClass();234 */235 }236 class TestExample extends Example1{237 public function myFunction2(){238 $var1 = self::class;239 }240 }241 class TestExample2 extends my\\test2\\Example1{}242 class TestExample3 extends aliasNamespace\\Example1{}243 class TestExample4 extends aliasClass{244 public function myFunction1(array $arg1, Example1 $arg2245 , my\\test2\\Example1 $arg3 = null246 , aliasNamespace\\Example1 $arg4247 , aliasClass $arg5){248 throw new \\LogicException();249 }250 }251 ');252 $parser = $this->initializeParser($mockSplFileInfo);253 $parser->parse();254 $this->assertSame('my\\test', $parser->getNamespace());255 $this->assertSame(['Example1'256 , 'my\\test2\\Example1'257 , 'my\\aliasNamespace\\Example1'258 , 'my\\test2\\Example2'259 , 'Example1'260 , 'my\\test2\\Example1'261 , 'my\\aliasNamespace\\Example1'262 , 'my\\test2\\Example2'263 , 'Exception'264 , 'MyException'265 , 'my\\test2\\MyException'266 , 'my\\aliasNamespace\\MyException'267 , 'my\\test2\\MyException'268 , 'Example1'269 , 'my\\test2\\Example1'270 , 'my\\aliasNamespace\\Example1'271 , 'my\\test2\\Example2'272 , 'Example1'273 , 'my\\test2\\Example1'274 , 'my\\aliasNamespace\\Example1'275 , 'my\\test2\\Example2'276 , 'LogicException'], $parser->getCalls());277 $this->assertSame([['use' => 'my\\aliasNamespace', 'alias' => 'aliasNamespace']278 , ['use' => 'my\\test2\\Example2', 'alias' => 'aliasClass']279 , ['use' => 'my\\test2\\MyException', 'alias' => 'aliasException']], $parser->getNamespaces());280 }281 /**282 * @test283 */284 public function parse_namespace()285 {286 $mockSplFileInfo = $this->createFileMock('<?php namespace test;');287 $parser = $this->initializeParser($mockSplFileInfo);288 $parser->parse();289 $this->assertSame('test', $parser->getNamespace());290 $this->assertSame([], $parser->getCalls());291 $this->assertSame([], $parser->getNamespaces());292 }293 /**294 * @test295 */296 public function parse_complexNamespace()297 {298 $mockSplFileInfo = $this->createFileMock('<?php namespace My\\FullNamespace\\test;');299 $parser = $this->initializeParser($mockSplFileInfo);300 $parser->parse();301 $this->assertSame('My\\FullNamespace\\test', $parser->getNamespace());302 $this->assertSame([], $parser->getCalls());303 $this->assertSame([], $parser->getNamespaces());304 }305 /**306 * @test307 */308 public function parse_useNamespaces()309 {310 $mockSplFileInfo = $this->createFileMock('<?php use My\\FullNamespace\\test;use My\\FullNamespace2\\test;use My\\AliasNamespace\\test as aliasTest;');311 $parser = $this->initializeParser($mockSplFileInfo);312 $parser->parse();313 $this->assertSame(null, $parser->getNamespace());314 $this->assertSame([], $parser->getCalls());315 $this->assertSame([['use' => 'My\\FullNamespace\\test', 'alias' => ''], ['use' => 'My\\FullNamespace2\\test', 'alias' => ''], ['use' => 'My\\AliasNamespace\\test', 'alias' => 'aliasTest']], $parser->getNamespaces());316 }317 /**318 * Parse Simple namespace operations319 */320 /**321 * @test322 */323 public function parse_new()324 {325 $mockSplFileInfo = $this->createFileMock('<?php $test = new Test();');326 $parser = $this->initializeParser($mockSplFileInfo);327 $parser->parse();328 $this->assertSame(null, $parser->getNamespace());329 $this->assertSame(['Test'], $parser->getCalls());330 $this->assertSame([], $parser->getNamespaces());331 }332 /**333 * @test334 */335 public function parse_new_withNamespace()336 {337 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; $test = new Test();');338 $parser = $this->initializeParser($mockSplFileInfo);339 $parser->parse();340 $this->assertSame('my\\Test', $parser->getNamespace());341 $this->assertSame(['Test'], $parser->getCalls());342 $this->assertSame([], $parser->getNamespaces());343 }344 /**345 * @test346 */347 public function parse_static()348 {349 $mockSplFileInfo = $this->createFileMock('<?php $var = Test::class;');350 $parser = $this->initializeParser($mockSplFileInfo);351 $parser->parse();352 $this->assertSame(null, $parser->getNamespace());353 $this->assertSame(['Test'], $parser->getCalls());354 $this->assertSame([], $parser->getNamespaces());355 }356 /**357 * @test358 */359 public function parse_static_withNamespace()360 {361 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; $var = Test::class;');362 $parser = $this->initializeParser($mockSplFileInfo);363 $parser->parse();364 $this->assertSame('my\\Test', $parser->getNamespace());365 $this->assertSame(['Test'], $parser->getCalls());366 $this->assertSame([], $parser->getNamespaces());367 }368 /**369 * @test370 */371 public function parse_extends()372 {373 $mockSplFileInfo = $this->createFileMock('<?php class test extends BaseTest{}');374 $parser = $this->initializeParser($mockSplFileInfo);375 $parser->parse();376 $this->assertSame(null, $parser->getNamespace());377 $this->assertSame(['BaseTest'], $parser->getCalls());378 $this->assertSame([], $parser->getNamespaces());379 }380 /**381 * @test382 */383 public function parse_extends_withNamespace()384 {385 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; class test extends BaseTest{}');386 $parser = $this->initializeParser($mockSplFileInfo);387 $parser->parse();388 $this->assertSame('my\\Test', $parser->getNamespace());389 $this->assertSame(['BaseTest'], $parser->getCalls());390 $this->assertSame([], $parser->getNamespaces());391 }392 /**393 * @test394 */395 public function parse_implements()396 {397 $mockSplFileInfo = $this->createFileMock('<?php class test implements TestInterface{}');398 $parser = $this->initializeParser($mockSplFileInfo);399 $parser->parse();400 $this->assertSame(null, $parser->getNamespace());401 $this->assertSame(['TestInterface'], $parser->getCalls());402 $this->assertSame([], $parser->getNamespaces());403 }404 /**405 * @test406 */407 public function parse_implements_withNamespace()408 {409 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; class test implements TestInterface{}');410 $parser = $this->initializeParser($mockSplFileInfo);411 $parser->parse();412 $this->assertSame('my\\Test', $parser->getNamespace());413 $this->assertSame(['TestInterface'], $parser->getCalls());414 $this->assertSame([], $parser->getNamespaces());415 }416 /**417 * @test418 */419 public function parse_catch()420 {421 $mockSplFileInfo = $this->createFileMock('<?php try{}catch(MyException $e){}');422 $parser = $this->initializeParser($mockSplFileInfo);423 $parser->parse();424 $this->assertSame(null, $parser->getNamespace());425 $this->assertSame(['MyException'], $parser->getCalls());426 $this->assertSame([], $parser->getNamespaces());427 }428 /**429 * @test430 */431 public function parse_catch_withNamespace()432 {433 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; try{}catch(MyException $e){}');434 $parser = $this->initializeParser($mockSplFileInfo);435 $parser->parse();436 $this->assertSame('my\\Test', $parser->getNamespace());437 $this->assertSame(['MyException'], $parser->getCalls());438 $this->assertSame([], $parser->getNamespaces());439 }440 /**441 * @test442 */443 public function parse_function()444 {445 $mockSplFileInfo = $this->createFileMock('<?php function myFunction(MyFunctionArgument1 $arg1, MyFunctionArgument2 $arg2, array $arg3)');446 $parser = $this->initializeParser($mockSplFileInfo);447 $parser->parse();448 $this->assertSame(null, $parser->getNamespace());449 $this->assertSame(['MyFunctionArgument1','MyFunctionArgument2'], $parser->getCalls());450 $this->assertSame([], $parser->getNamespaces());451 }452 /**453 * @test454 */455 public function parse_function_withNamespace()456 {457 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; function myFunction(MyFunctionArgument1 $arg1, MyFunctionArgument2 $arg2, array $arg3)');458 $parser = $this->initializeParser($mockSplFileInfo);459 $parser->parse();460 $this->assertSame('my\\Test', $parser->getNamespace());461 $this->assertSame(['MyFunctionArgument1','MyFunctionArgument2'], $parser->getCalls());462 $this->assertSame([], $parser->getNamespaces());463 }464 /**465 * @test466 */467 public function parseAnnotation(){468 $mockSplFileInfo = $this->createFileMock('<?php469 use my\\aliasNamespace as aliasNamespace;470 use my\\test2\\Example2 as aliasClass;471 /**472 * @param Example1 $arg1473 * @param \\my\\FullNamespace\\Example1 $arg2474 * @param aliasNamespace\\Example1 $arg3475 * @param aliasClass $arg4476 * @return \\my\\FullNamespace\\Example1477 */478 function myFunction($arg1, $arg2, $arg3, $arg4){479 /* @var $var1 Example1*/480 $var1 = null;481 /* @var $var2 \\my\\FullNamespace\\Example1*/482 $var2 = null;483 /* @var $var3 aliasNamespace\\Example1*/484 $var3 = null;485 /* @var $var4 aliasClass*/486 $var4 = null;487 /* @var $var5 array */488 $var5 = [];489 /* @var $var6 mixed */490 $var6 = [];491 }');492 $parser = $this->initializeParser($mockSplFileInfo);493 $parser->parse();494 $this->assertSame(null, $parser->getNamespace());495 $this->assertSame(['Example1'496 ,'my\\FullNamespace\\Example1'497 ,'my\\aliasNamespace\\Example1'498 ,'my\\test2\\Example2'499 ,'my\\FullNamespace\\Example1'500 ,'Example1'501 ,'my\\FullNamespace\\Example1'502 ,'my\\aliasNamespace\\Example1'503 ,'my\\test2\\Example2'504 ,'array'505 ,'mixed'], $parser->getCalls());506 $this->assertSame([['use' => 'my\\aliasNamespace','alias' => 'aliasNamespace'],['use' => 'my\\test2\\Example2','alias' => 'aliasClass']], $parser->getNamespaces());507 }508 /**509 * Parse full namespace operations510 */511 /**512 * @test513 */514 public function parse_new_withFullNamespace()515 {516 $mockSplFileInfo = $this->createFileMock('<?php $test = new \\My\\FullNamespace\\Test();');517 $parser = $this->initializeParser($mockSplFileInfo);518 $parser->parse();519 $this->assertSame(null, $parser->getNamespace());520 $this->assertSame(['My\\FullNamespace\\Test'], $parser->getCalls());521 $this->assertSame([], $parser->getNamespaces());522 }523 /**524 * @test525 */526 public function parse_new_withFullNamespace_withNamespace()527 {528 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; $test = new My\\FullNamespace\\Test();');529 $parser = $this->initializeParser($mockSplFileInfo);530 $parser->parse();531 $this->assertSame('my\\Test', $parser->getNamespace());532 $this->assertSame(['My\\FullNamespace\\Test'], $parser->getCalls());533 $this->assertSame([], $parser->getNamespaces());534 }535 /**536 * @test537 */538 public function parse_static_withFullNamespace()539 {540 $mockSplFileInfo = $this->createFileMock('<?php $var = \\My\\FullNamespace\\Test::class;');541 $parser = $this->initializeParser($mockSplFileInfo);542 $parser->parse();543 $this->assertSame(null, $parser->getNamespace());544 $this->assertSame(['My\\FullNamespace\\Test'], $parser->getCalls());545 $this->assertSame([], $parser->getNamespaces());546 }547 /**548 * @test549 */550 public function parse_static_withFullNamespace_withNamespace()551 {552 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; $var = My\\FullNamespace\\Test::class;');553 $parser = $this->initializeParser($mockSplFileInfo);554 $parser->parse();555 $this->assertSame('my\\Test', $parser->getNamespace());556 $this->assertSame(['My\\FullNamespace\\Test'], $parser->getCalls());557 $this->assertSame([], $parser->getNamespaces());558 }559 /**560 * @test561 */562 public function parse_extends_withFullNamespace()563 {564 $mockSplFileInfo = $this->createFileMock('<?php class test extends \\My\\FullNamespace\\BaseTest{}');565 $parser = $this->initializeParser($mockSplFileInfo);566 $parser->parse();567 $this->assertSame(null, $parser->getNamespace());568 $this->assertSame(['My\\FullNamespace\\BaseTest'], $parser->getCalls());569 $this->assertSame([], $parser->getNamespaces());570 }571 /**572 * @test573 */574 public function parse_extends_withFullNamespace_withNamespace()575 {576 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; class test extends My\\FullNamespace\\BaseTest{}');577 $parser = $this->initializeParser($mockSplFileInfo);578 $parser->parse();579 $this->assertSame('my\\Test', $parser->getNamespace());580 $this->assertSame(['My\\FullNamespace\\BaseTest'], $parser->getCalls());581 $this->assertSame([], $parser->getNamespaces());582 }583 /**584 * @test585 */586 public function parse_implements_withFullNamespace()587 {588 $mockSplFileInfo = $this->createFileMock('<?php class test implements \\My\\FullNamespace\\TestInterface{}');589 $parser = $this->initializeParser($mockSplFileInfo);590 $parser->parse();591 $this->assertSame(null, $parser->getNamespace());592 $this->assertSame(['My\\FullNamespace\\TestInterface'], $parser->getCalls());593 $this->assertSame([], $parser->getNamespaces());594 }595 /**596 * @test597 */598 public function parse_implements_withFullNamespace_withNamespace()599 {600 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; class test implements My\\FullNamespace\\TestInterface{}');601 $parser = $this->initializeParser($mockSplFileInfo);602 $parser->parse();603 $this->assertSame('my\\Test', $parser->getNamespace());604 $this->assertSame(['My\\FullNamespace\\TestInterface'], $parser->getCalls());605 $this->assertSame([], $parser->getNamespaces());606 }607 /**608 * @test609 */610 public function parse_catch_withFullNamespace()611 {612 $mockSplFileInfo = $this->createFileMock('<?php try{}catch(\\My\\FullNamespace\\MyException $e){}');613 $parser = $this->initializeParser($mockSplFileInfo);614 $parser->parse();615 $this->assertSame(null, $parser->getNamespace());616 $this->assertSame(['My\\FullNamespace\\MyException'], $parser->getCalls());617 $this->assertSame([], $parser->getNamespaces());618 }619 /**620 * @test621 */622 public function parse_catch_withFullNamespace_withNamespace()623 {624 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; try{}catch(My\\FullNamespace\\MyException $e){}');625 $parser = $this->initializeParser($mockSplFileInfo);626 $parser->parse();627 $this->assertSame('my\\Test', $parser->getNamespace());628 $this->assertSame(['My\\FullNamespace\\MyException'], $parser->getCalls());629 $this->assertSame([], $parser->getNamespaces());630 }631 /**632 * @test633 */634 public function parse_function_withFullNamespaces()635 {636 $mockSplFileInfo = $this->createFileMock('<?php function myFunction(\\my\\FullNamespace\\MyFunctionArgument1 $arg1, \\my\\FullNamespace\\MyFunctionArgument2 $arg2, array $arg3)');637 $parser = $this->initializeParser($mockSplFileInfo);638 $parser->parse();639 $this->assertSame(null, $parser->getNamespace());640 $this->assertSame(['my\\FullNamespace\\MyFunctionArgument1','my\\FullNamespace\\MyFunctionArgument2'], $parser->getCalls());641 $this->assertSame([], $parser->getNamespaces());642 }643 /**644 * @test645 */646 public function parse_function_withFullNamespaces_withNamespace()647 {648 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; function myFunction(my\\FullNamespace\\MyFunctionArgument1 $arg1, my\\FullNamespace\\MyFunctionArgument2 $arg2, array $arg3)');649 $parser = $this->initializeParser($mockSplFileInfo);650 $parser->parse();651 $this->assertSame('my\\Test', $parser->getNamespace());652 $this->assertSame(['my\\FullNamespace\\MyFunctionArgument1','my\\FullNamespace\\MyFunctionArgument2'], $parser->getCalls());653 $this->assertSame([], $parser->getNamespaces());654 }655 /**656 * Parse used namespace operations657 */658 /**659 * @test660 */661 public function parse_new_withUsedNamespace()662 {663 $mockSplFileInfo = $this->createFileMock('<?php use My\\FullNamespace\\Test; $test = new Test();');664 $parser = $this->initializeParser($mockSplFileInfo);665 $parser->parse();666 $this->assertSame(null, $parser->getNamespace());667 $this->assertSame(['My\\FullNamespace\\Test'], $parser->getCalls());668 $this->assertSame([['use' => 'My\\FullNamespace\\Test', 'alias' => '']], $parser->getNamespaces());669 }670 /**671 * @test672 */673 public function parse_new_withUsedNamespace_withNamespace()674 {675 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; use My\\FullNamespace\\Test; $test = new Test();');676 $parser = $this->initializeParser($mockSplFileInfo);677 $parser->parse();678 $this->assertSame('my\\Test', $parser->getNamespace());679 $this->assertSame(['My\\FullNamespace\\Test'], $parser->getCalls());680 $this->assertSame([['use' => 'My\\FullNamespace\\Test', 'alias' => '']], $parser->getNamespaces());681 }682 /**683 * @test684 */685 public function parse_static_withUsedNamespace()686 {687 $mockSplFileInfo = $this->createFileMock('<?php use My\\FullNamespace\\Test; $var = Test::class;');688 $parser = $this->initializeParser($mockSplFileInfo);689 $parser->parse();690 $this->assertSame(null, $parser->getNamespace());691 $this->assertSame(['My\\FullNamespace\\Test'], $parser->getCalls());692 $this->assertSame([['use' => 'My\\FullNamespace\\Test', 'alias' => '']], $parser->getNamespaces());693 }694 /**695 * @test696 */697 public function parse_static_withUsedNamespace_withNamespace()698 {699 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; use My\\FullNamespace\\Test; $var = Test::class;');700 $parser = $this->initializeParser($mockSplFileInfo);701 $parser->parse();702 $this->assertSame('my\\Test', $parser->getNamespace());703 $this->assertSame(['My\\FullNamespace\\Test'], $parser->getCalls());704 $this->assertSame([['use' => 'My\\FullNamespace\\Test', 'alias' => '']], $parser->getNamespaces());705 }706 /**707 * @test708 */709 public function parse_extends_withUsedNamespace()710 {711 $mockSplFileInfo = $this->createFileMock('<?php use My\\FullNamespace\\BaseTest; class test extends BaseTest{}');712 $parser = $this->initializeParser($mockSplFileInfo);713 $parser->parse();714 $this->assertSame(null, $parser->getNamespace());715 $this->assertSame(['My\\FullNamespace\\BaseTest'], $parser->getCalls());716 $this->assertSame([['use' => 'My\\FullNamespace\\BaseTest', 'alias' => '']], $parser->getNamespaces());717 }718 /**719 * @test720 */721 public function parse_extends_withUsedNamespace_withNamespace()722 {723 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; use My\\FullNamespace\\BaseTest; class test extends BaseTest{}');724 $parser = $this->initializeParser($mockSplFileInfo);725 $parser->parse();726 $this->assertSame('my\\Test', $parser->getNamespace());727 $this->assertSame(['My\\FullNamespace\\BaseTest'], $parser->getCalls());728 $this->assertSame([['use' => 'My\\FullNamespace\\BaseTest', 'alias' => '']], $parser->getNamespaces());729 }730 /**731 * @test732 */733 public function parse_implements_withUsedNamespace()734 {735 $mockSplFileInfo = $this->createFileMock('<?php use My\\FullNamespace\\TestInterface; class test implements TestInterface{}');736 $parser = $this->initializeParser($mockSplFileInfo);737 $parser->parse();738 $this->assertSame(null, $parser->getNamespace());739 $this->assertSame(['My\\FullNamespace\\TestInterface'], $parser->getCalls());740 $this->assertSame([['use' => 'My\\FullNamespace\\TestInterface', 'alias' => '']], $parser->getNamespaces());741 }742 /**743 * @test744 */745 public function parse_implements_withUsedNamespace_withNamespace()746 {747 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; use My\\FullNamespace\\TestInterface; class test implements TestInterface{}');748 $parser = $this->initializeParser($mockSplFileInfo);749 $parser->parse();750 $this->assertSame('my\\Test', $parser->getNamespace());751 $this->assertSame(['My\\FullNamespace\\TestInterface'], $parser->getCalls());752 $this->assertSame([['use' => 'My\\FullNamespace\\TestInterface', 'alias' => '']], $parser->getNamespaces());753 }754 /**755 * @test756 */757 public function parse_catch_withUsedNamespace()758 {759 $mockSplFileInfo = $this->createFileMock('<?php use My\\FullNamespace\\MyException; try{}catch(MyException $e){}');760 $parser = $this->initializeParser($mockSplFileInfo);761 $parser->parse();762 $this->assertSame(null, $parser->getNamespace());763 $this->assertSame(['My\\FullNamespace\\MyException'], $parser->getCalls());764 $this->assertSame([['use' => 'My\\FullNamespace\\MyException', 'alias' => '']], $parser->getNamespaces());765 }766 /**767 * @test768 */769 public function parse_catch_withUsedNamespace_withNamespace()770 {771 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; use My\\FullNamespace\\MyException; try{}catch(MyException $e){}');772 $parser = $this->initializeParser($mockSplFileInfo);773 $parser->parse();774 $this->assertSame('my\\Test', $parser->getNamespace());775 $this->assertSame(['My\\FullNamespace\\MyException'], $parser->getCalls());776 $this->assertSame([['use' => 'My\\FullNamespace\\MyException', 'alias' => '']], $parser->getNamespaces());777 }778 /**779 * @test780 */781 public function parse_function_withUsedNamespaces()782 {783 $mockSplFileInfo = $this->createFileMock('<?php784 use my\\FullNamespace\\MyFunctionArgument1;785 use my\\FullNamespace\\MyFunctionArgument2;786 function myFunction(MyFunctionArgument1 $arg1, MyFunctionArgument2 $arg2, array $arg3)');787 $parser = $this->initializeParser($mockSplFileInfo);788 $parser->parse();789 $this->assertSame(null, $parser->getNamespace());790 $this->assertSame(['my\\FullNamespace\\MyFunctionArgument1','my\\FullNamespace\\MyFunctionArgument2'], $parser->getCalls());791 $this->assertSame([['use' => 'my\\FullNamespace\\MyFunctionArgument1','alias' => ''],792 ['use' => 'my\\FullNamespace\\MyFunctionArgument2','alias' => '']], $parser->getNamespaces());793 }794 /**795 * @test796 */797 public function parse_function_withUsedNamespaces_withNamespace()798 {799 $mockSplFileInfo = $this->createFileMock('<?php800 namespace my\\Test;801 use my\\FullNamespace\\MyFunctionArgument1;802 use my\\FullNamespace\\MyFunctionArgument2;803 function myFunction(MyFunctionArgument1 $arg1, MyFunctionArgument2 $arg2, array $arg3)');804 $parser = $this->initializeParser($mockSplFileInfo);805 $parser->parse();806 $this->assertSame('my\\Test', $parser->getNamespace());807 $this->assertSame(['my\\FullNamespace\\MyFunctionArgument1','my\\FullNamespace\\MyFunctionArgument2'], $parser->getCalls());808 $this->assertSame([['use' => 'my\\FullNamespace\\MyFunctionArgument1','alias' => ''],809 ['use' => 'my\\FullNamespace\\MyFunctionArgument2','alias' => '']], $parser->getNamespaces());810 }811 /**812 * Parse namespace class alias operations813 */814 /**815 * @test816 */817 public function parse_new_withUsedAlias()818 {819 $mockSplFileInfo = $this->createFileMock('<?php use My\\FullNamespace\\Test as myTest; $test = new myTest();');820 $parser = $this->initializeParser($mockSplFileInfo);821 $parser->parse();822 $this->assertSame(null, $parser->getNamespace());823 $this->assertSame(['My\\FullNamespace\\Test'], $parser->getCalls());824 $this->assertSame([['use' => 'My\\FullNamespace\\Test', 'alias' => 'myTest']], $parser->getNamespaces());825 }826 /**827 * @test828 */829 public function parse_new_withUsedAlias_withNamespace()830 {831 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; use My\\FullNamespace\\Test as myTest; $test = new myTest();');832 $parser = $this->initializeParser($mockSplFileInfo);833 $parser->parse();834 $this->assertSame('my\\Test', $parser->getNamespace());835 $this->assertSame(['My\\FullNamespace\\Test'], $parser->getCalls());836 $this->assertSame([['use' => 'My\\FullNamespace\\Test', 'alias' => 'myTest']], $parser->getNamespaces());837 }838 /**839 * @test840 */841 public function parse_static_withUsedAlias()842 {843 $mockSplFileInfo = $this->createFileMock('<?php use My\\FullNamespace\\Test as myTest; $var = myTest::class;');844 $parser = $this->initializeParser($mockSplFileInfo);845 $parser->parse();846 $this->assertSame(null, $parser->getNamespace());847 $this->assertSame(['My\\FullNamespace\\Test'], $parser->getCalls());848 $this->assertSame([['use' => 'My\\FullNamespace\\Test', 'alias' => 'myTest']], $parser->getNamespaces());849 }850 /**851 * @test852 */853 public function parse_static_withUsedAlias_withNamespace()854 {855 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; use My\\FullNamespace\\Test as myTest; $var = myTest::class;');856 $parser = $this->initializeParser($mockSplFileInfo);857 $parser->parse();858 $this->assertSame('my\\Test', $parser->getNamespace());859 $this->assertSame(['My\\FullNamespace\\Test'], $parser->getCalls());860 $this->assertSame([['use' => 'My\\FullNamespace\\Test', 'alias' => 'myTest']], $parser->getNamespaces());861 }862 /**863 * @test864 */865 public function parse_extends_withUsedAlias()866 {867 $mockSplFileInfo = $this->createFileMock('<?php use My\\FullNamespace\\BaseTest as MyTest; class test extends MyTest{}');868 $parser = $this->initializeParser($mockSplFileInfo);869 $parser->parse();870 $this->assertSame(null, $parser->getNamespace());871 $this->assertSame(['My\\FullNamespace\\BaseTest'], $parser->getCalls());872 $this->assertSame([['use' => 'My\\FullNamespace\\BaseTest', 'alias' => 'MyTest']], $parser->getNamespaces());873 }874 /**875 * @test876 */877 public function parse_extends_withUsedAlias_withNamespace()878 {879 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; use My\\FullNamespace\\BaseTest as MyTest; class test extends MyTest{}');880 $parser = $this->initializeParser($mockSplFileInfo);881 $parser->parse();882 $this->assertSame('my\\Test', $parser->getNamespace());883 $this->assertSame(['My\\FullNamespace\\BaseTest'], $parser->getCalls());884 $this->assertSame([['use' => 'My\\FullNamespace\\BaseTest', 'alias' => 'MyTest']], $parser->getNamespaces());885 }886 /**887 * @test888 */889 public function parse_implements_withUsedAlias()890 {891 $mockSplFileInfo = $this->createFileMock('<?php use My\\FullNamespace\\TestInterface as MyInterface; class test implements MyInterface{}');892 $parser = $this->initializeParser($mockSplFileInfo);893 $parser->parse();894 $this->assertSame(null, $parser->getNamespace());895 $this->assertSame(['My\\FullNamespace\\TestInterface'], $parser->getCalls());896 $this->assertSame([['use' => 'My\\FullNamespace\\TestInterface', 'alias' => 'MyInterface']], $parser->getNamespaces());897 }898 /**899 * @test900 */901 public function parse_implements_withUsedAlias_withNamespace()902 {903 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; use My\\FullNamespace\\TestInterface as MyInterface; class test implements MyInterface{}');904 $parser = $this->initializeParser($mockSplFileInfo);905 $parser->parse();906 $this->assertSame('my\\Test', $parser->getNamespace());907 $this->assertSame(['My\\FullNamespace\\TestInterface'], $parser->getCalls());908 $this->assertSame([['use' => 'My\\FullNamespace\\TestInterface', 'alias' => 'MyInterface']], $parser->getNamespaces());909 }910 /**911 * @test912 */913 public function parse_catch_withUsedAlias()914 {915 $mockSplFileInfo = $this->createFileMock('<?php use My\\FullNamespace\\MyException as testException; try{}catch(testException $e){}');916 $parser = $this->initializeParser($mockSplFileInfo);917 $parser->parse();918 $this->assertSame(null, $parser->getNamespace());919 $this->assertSame(['My\\FullNamespace\\MyException'], $parser->getCalls());920 $this->assertSame([['use' => 'My\\FullNamespace\\MyException', 'alias' => 'testException']], $parser->getNamespaces());921 }922 /**923 * @test924 */925 public function parse_catch_withUsedAlias_withNamespace()926 {927 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; use My\\FullNamespace\\MyException as testException; try{}catch(testException $e){}');928 $parser = $this->initializeParser($mockSplFileInfo);929 $parser->parse();930 $this->assertSame('my\\Test', $parser->getNamespace());931 $this->assertSame(['My\\FullNamespace\\MyException'], $parser->getCalls());932 $this->assertSame([['use' => 'My\\FullNamespace\\MyException', 'alias' => 'testException']], $parser->getNamespaces());933 }934 /**935 * @test936 */937 public function parse_function_withUsedAlias()938 {939 $mockSplFileInfo = $this->createFileMock('<?php940 use my\\FullNamespace\\MyFunctionArgument1 as Arg1;941 use my\\FullNamespace\\MyFunctionArgument2 as Arg2;942 function myFunction(array $arg3 = [],Arg1 $arg1, Arg2 $arg2)');943 $parser = $this->initializeParser($mockSplFileInfo);944 $parser->parse();945 $this->assertSame(null, $parser->getNamespace());946 $this->assertSame(['my\\FullNamespace\\MyFunctionArgument1','my\\FullNamespace\\MyFunctionArgument2'], $parser->getCalls());947 $this->assertSame([['use' => 'my\\FullNamespace\\MyFunctionArgument1','alias' => 'Arg1'],948 ['use' => 'my\\FullNamespace\\MyFunctionArgument2','alias' => 'Arg2']], $parser->getNamespaces());949 }950 /**951 * @test952 */953 public function parse_function_withUsedAlias_withNamespace()954 {955 $mockSplFileInfo = $this->createFileMock('<?php956 namespace my\\Test;957 use my\\FullNamespace\\MyFunctionArgument1 as Arg1;958 use my\\FullNamespace\\MyFunctionArgument2 as Arg2;959 function myFunction(array $arg3 = null,Arg1 $arg1, Arg2 $arg2)');960 $parser = $this->initializeParser($mockSplFileInfo);961 $parser->parse();962 $this->assertSame('my\\Test', $parser->getNamespace());963 $this->assertSame(['my\\FullNamespace\\MyFunctionArgument1','my\\FullNamespace\\MyFunctionArgument2'], $parser->getCalls());964 $this->assertSame([['use' => 'my\\FullNamespace\\MyFunctionArgument1','alias' => 'Arg1'],965 ['use' => 'my\\FullNamespace\\MyFunctionArgument2','alias' => 'Arg2']], $parser->getNamespaces());966 }967 /**968 * Parse namespace alias operations969 */970 /**971 * @test972 */973 public function parse_new_withUsedNamespaceAlias()974 {975 $mockSplFileInfo = $this->createFileMock('<?php use My\\FullNamespace as myTest; $test = new myTest\Test();');976 $parser = $this->initializeParser($mockSplFileInfo);977 $parser->parse();978 $this->assertSame(null, $parser->getNamespace());979 $this->assertSame(['My\\FullNamespace\\Test'], $parser->getCalls());980 $this->assertSame([['use' => 'My\\FullNamespace', 'alias' => 'myTest']], $parser->getNamespaces());981 }982 /**983 * @test984 */985 public function parse_new_withUsedNamespaceAlias_withNamespace()986 {987 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; use My\\FullNamespace as myTest; $test = new myTest\Test();');988 $parser = $this->initializeParser($mockSplFileInfo);989 $parser->parse();990 $this->assertSame('my\\Test', $parser->getNamespace());991 $this->assertSame(['My\\FullNamespace\\Test'], $parser->getCalls());992 $this->assertSame([['use' => 'My\\FullNamespace', 'alias' => 'myTest']], $parser->getNamespaces());993 }994 /**995 * @test996 */997 public function parse_static_withUsedNamespaceAlias()998 {999 $mockSplFileInfo = $this->createFileMock('<?php use My\\FullNamespace as myTest; $var = myTest\\Test::class;');1000 $parser = $this->initializeParser($mockSplFileInfo);1001 $parser->parse();1002 $this->assertSame(null, $parser->getNamespace());1003 $this->assertSame(['My\\FullNamespace\\Test'], $parser->getCalls());1004 $this->assertSame([['use' => 'My\\FullNamespace', 'alias' => 'myTest']], $parser->getNamespaces());1005 }1006 /**1007 * @test1008 */1009 public function parse_static_withUsedNamespaceAlias_withNamespace()1010 {1011 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; use My\\FullNamespace as myTest; $var = myTest\\Test::class;');1012 $parser = $this->initializeParser($mockSplFileInfo);1013 $parser->parse();1014 $this->assertSame('my\\Test', $parser->getNamespace());1015 $this->assertSame(['My\\FullNamespace\\Test'], $parser->getCalls());1016 $this->assertSame([['use' => 'My\\FullNamespace', 'alias' => 'myTest']], $parser->getNamespaces());1017 }1018 /**1019 * @test1020 */1021 public function parse_extends_withUsedNamespaceAlias()1022 {1023 $mockSplFileInfo = $this->createFileMock('<?php use My\\FullNamespace as MyTest; class test extends MyTest\\BaseTest{}');1024 $parser = $this->initializeParser($mockSplFileInfo);1025 $parser->parse();1026 $this->assertSame(null, $parser->getNamespace());1027 $this->assertSame(['My\\FullNamespace\\BaseTest'], $parser->getCalls());1028 $this->assertSame([['use' => 'My\\FullNamespace', 'alias' => 'MyTest']], $parser->getNamespaces());1029 }1030 /**1031 * @test1032 */1033 public function parse_extends_withUsedNamespaceAlias_withNamespace()1034 {1035 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; use My\\FullNamespace as MyTest; class test extends MyTest\\BaseTest{}');1036 $parser = $this->initializeParser($mockSplFileInfo);1037 $parser->parse();1038 $this->assertSame('my\\Test', $parser->getNamespace());1039 $this->assertSame(['My\\FullNamespace\\BaseTest'], $parser->getCalls());1040 $this->assertSame([['use' => 'My\\FullNamespace', 'alias' => 'MyTest']], $parser->getNamespaces());1041 }1042 /**1043 * @test1044 */1045 public function parse_implements_withUsedNamespaceAlias()1046 {1047 $mockSplFileInfo = $this->createFileMock('<?php use My\\FullNamespace as MyTest; class test implements MyTest\\TestInterface{}');1048 $parser = $this->initializeParser($mockSplFileInfo);1049 $parser->parse();1050 $this->assertSame(null, $parser->getNamespace());1051 $this->assertSame(['My\\FullNamespace\\TestInterface'], $parser->getCalls());1052 $this->assertSame([['use' => 'My\\FullNamespace', 'alias' => 'MyTest']], $parser->getNamespaces());1053 }1054 /**1055 * @test1056 */1057 public function parse_implements_withUsedNamespaceAlias_withNamespace()1058 {1059 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; use My\\FullNamespace as MyTest; class test implements MyTest\\TestInterface{}');1060 $parser = $this->initializeParser($mockSplFileInfo);1061 $parser->parse();1062 $this->assertSame('my\\Test', $parser->getNamespace());1063 $this->assertSame(['My\\FullNamespace\\TestInterface'], $parser->getCalls());1064 $this->assertSame([['use' => 'My\\FullNamespace', 'alias' => 'MyTest']], $parser->getNamespaces());1065 }1066 /**1067 * @test1068 */1069 public function parse_catch_withUsedNamespaceAlias()1070 {1071 $mockSplFileInfo = $this->createFileMock('<?php use My\\FullNamespace as testException; try{}catch(testException\\MyException $e){}');1072 $parser = $this->initializeParser($mockSplFileInfo);1073 $parser->parse();1074 $this->assertSame(null, $parser->getNamespace());1075 $this->assertSame(['My\\FullNamespace\\MyException'], $parser->getCalls());1076 $this->assertSame([['use' => 'My\\FullNamespace', 'alias' => 'testException']], $parser->getNamespaces());1077 }1078 /**1079 * @test1080 */1081 public function parse_catch_withUsedNamespaceAlias_withNamespace()1082 {1083 $mockSplFileInfo = $this->createFileMock('<?php namespace my\\Test; use My\\FullNamespace as testException; try{}catch(testException\\MyException $e){}');1084 $parser = $this->initializeParser($mockSplFileInfo);1085 $parser->parse();1086 $this->assertSame('my\\Test', $parser->getNamespace());1087 $this->assertSame(['My\\FullNamespace\\MyException'], $parser->getCalls());1088 $this->assertSame([['use' => 'My\\FullNamespace', 'alias' => 'testException']], $parser->getNamespaces());1089 }1090 /**1091 * @test1092 */1093 public function parse_function_withUsedNamespaceAlias()1094 {1095 $mockSplFileInfo = $this->createFileMock('<?php1096 use my\\FullNamespace as Args;1097 function myFunction(Args\\MyFunctionArgument1 $arg1, Args\\MyFunctionArgument2 $arg2, array $arg3)');1098 $parser = $this->initializeParser($mockSplFileInfo);1099 $parser->parse();1100 $this->assertSame(null, $parser->getNamespace());1101 $this->assertSame(['my\\FullNamespace\\MyFunctionArgument1','my\\FullNamespace\\MyFunctionArgument2'], $parser->getCalls());1102 $this->assertSame([['use' => 'my\\FullNamespace','alias' => 'Args']], $parser->getNamespaces());1103 }1104 /**1105 * @test1106 */1107 public function parse_function_withUsedNamespaceAlias_withNamespace()1108 {1109 $mockSplFileInfo = $this->createFileMock('<?php1110 namespace my\\Test;1111 use my\\FullNamespace as Args;1112 function myFunction(Args\\MyFunctionArgument1 $arg1, Args\\MyFunctionArgument2 $arg2, array $arg3)');1113 $parser = $this->initializeParser($mockSplFileInfo);1114 $parser->parse();1115 $this->assertSame('my\\Test', $parser->getNamespace());1116 $this->assertSame(['my\\FullNamespace\\MyFunctionArgument1','my\\FullNamespace\\MyFunctionArgument2'], $parser->getCalls());1117 $this->assertSame([['use' => 'my\\FullNamespace','alias' => 'Args']], $parser->getNamespaces());1118 }1119 private function initializeParser(SplFileInfo $mockSplFileInfo){1120 $parser = new PHPFileParser($mockSplFileInfo);1121 $parser->addParser(new NewParser());1122 $parser->addParser(new StaticParser());1123 $parser->addParser(new ExtendsParser());1124 $parser->addParser(new ImplementsParser());1125 $parser->addParser(new CatchParser());1126 $parser->addParser(new ArgumentParser());1127 $parser->addParser(new InstanceOfParser());1128 $parser->addParser(new AnnotationParser());1129 return $parser;1130 }1131 private function createFileMock($content)...

Full Screen

Full Screen

Title.php

Source:Title.php Github

copy

Full Screen

...212 case 'fullbasepagename':213 if ($t->getNameSpace() == NS_MAIN) {214 return $t->getBaseText();215 } else {216 return str_replace('_',' ',$wgContLang->getNsText( $t->getNamespace() ) ) 217 . ':'218 . $t->getBaseText();219 }220 case 'fullbasepagenamee':221 if ($t->getNameSpace() == NS_MAIN) {222 return wfUrlEncode( str_replace( ' ', '_', $t->getBaseText() ) );223 } else {224 return wfUrlencode( $wgContLang->getNsText( $t->getNamespace() ) ) 225 . ':'226 . wfUrlEncode( str_replace( ' ', '_', $t->getBaseText() ) );227 }228 case 'rootpagename':229 if( isset( $wgNamespacesWithSubpages[ $t->getNamespace() ] ) && $wgNamespacesWithSubpages[ $t->getNamespace() ] ) {230 $parts = explode( '/', $t->getText(),2 );231 return $parts[0];232 } else {233 return $t->getText();234 }235 case 'rootpagenamee':236 if( isset( $wgNamespacesWithSubpages[ $t->getNamespace() ] ) && $wgNamespacesWithSubpages[ $t->getNamespace() ] ) {237 $parts = explode( '/', $t->getPartialURL(),2 );238 return $parts[0];239 } else {240 return $t->getPartialURL();241 }242 case 'fullrootpagename':243 if( isset( $wgNamespacesWithSubpages[ $t->getNamespace() ] ) && $wgNamespacesWithSubpages[ $t->getNamespace() ] ) {244 $parts = explode( '/', $t->getPrefixedText(),2 );245 return $parts[0];246 } else {247 return $t->getPrefixedText();248 }249 case 'fullrootpagenamee':250 if( isset( $wgNamespacesWithSubpages[ $t->getNamespace() ] ) && $wgNamespacesWithSubpages[ $t->getNamespace() ] ) {251 $parts = explode( '/', $t->getPrefixedURL(),2 );252 return $parts[0];253 } else {254 return $t->getPrefixedURL();255 }256 case 'talkpagename':257 if( $t->canTalk() ) {258 $talkPage = $t->getTalkPage();259 return $talkPage->getPrefixedText();260 } else {261 return '';262 }263 case 'talkpagenamee':264 if( $t->canTalk() ) {265 $talkPage = $t->getTalkPage();266 return $talkPage->getPrefixedUrl();267 } else {268 return '';269 }270 case 'subjectpagename':271 $subjPage = $t->getSubjectPage();272 return $subjPage->getPrefixedText();273 case 'subjectpagenamee':274 $subjPage = $t->getSubjectPage();275 return $subjPage->getPrefixedUrl();276 case 'nslocal':277 case 'namespace':278 return str_replace('_',' ',$wgContLang->getNsText( $t->getNamespace() ) );279 case 'nslocale':280 case 'namespacee':281 return wfUrlencode( $wgContLang->getNsText( $t->getNamespace() ) );282 case 'ns':283 case 'nscanonical':284 return str_replace('_',' ', /*Namespace::getCanonicalName*/ $wgContLang->getNsText($t->getNamespace()) );285 case 'nse':286 case 'nscanonicale':287 return wfUrlencode( /*Namespace::getCanonicalName*/ $wgContLang->getNsText($t->getNamespace()) );288 case 'nsnumber':289 return $t->getNamespace();290 case 'talkspace':291 return $t->canTalk() ? str_replace('_',' ',$t->getTalkNsText()) : '';292 case 'talkspacee':293 return $t->canTalk() ? wfUrlencode( $t->getTalkNsText() ) : '';294 case 'subjectspace':295 return $t->getSubjectNsText();296 case 'subjectspacee':297 return( wfUrlencode( $t->getSubjectNsText() ) ); 298 case 'issubpage':299 return strpos($t->getText(),'/') > -1 ? 'ISSUBPAGE' : ''; 300 case 'subpagelevel':301 return strpos($t->getText(),'/') > -1 ? (count(explode('/',$t->getText()))-1)-'': '0'; 302 default: return $this->notFound();303 }304 }305 306 var $titlePath = null;307 308 function fl_title(&$parser, $f, $a, $titleText=null) {309 global $wgContLang,$wgNamespacesWithSubpages;310 $args = new xxxArgs($f,$a);311 $title = $args->trimExpand(1);312 if(!$title) {313 if ($args->command=='link') return $args->trimExpand($args->count);314 return array('found'=>false);315 } 316 $t=Title::newFromText($title);317 if ($t) {318 switch($args->command)319 {320 case 'fullurl':321 return $t->getFullUrl($this->makeUrlQuery($args));322 case 'fullurle':323 return wfUrlencode($t->getFullUrl($this->makeUrlQuery($args)));324 case 'localurl':325 case 'url':326 return $t->getLocalUrl($this->makeUrlQuery($args));327 case 'localurle':328 case 'urle':329 return wfUrlencode($t->getLocalUrl($this->makeUrlQuery($args))); 330 case 'path':331 return $this->makePath($t,$args); 332 case 'link':333 if (!$this->title_path) {334 $dbr = wfGetDB( DB_SLAVE );335 $this->title_path = $dbr->selectField('page_props','pp_value', array( 336 'pp_page' => $parser->mTitle->getArticleId(),337 'pp_propname' => 'title_path'338 ), __METHOD__ );339 340 if (!$this->title_path) $this->title_path = $parser->mTitle->getFullText();341 }342 343 if ($args->count > 2 && $args->isNumbered($args->count))344 $display=$args->cropExpand($args->count);345 elseif ($args->count > 3 && $args->trimExpand($args->count-1) == '') 346 $display=$args->cropExpand($args->count);347 else348 $display=$t->getFullText();349 if ($t->getFullText()==$parser->mTitle->getFullText()) {350 $class = 'link-self'; 351 } elseif (stripos($this->title_path."/",$t->getFullText())===0) {352 $class = 'link-active';353 }354 $html = '<a href="' 355 . $t->getLinkUrl($this->makeUrlQuery($args))356 . '" '357 . $this->makeHtmlAttributes($args,array('class'=>"link $class"))358 .'><span class="link-inner">' 359 . $display 360 .'</span></a>';361 return array($html, 'isHTML'=>true);362 default: 363 return $this->titleFunctions($parser,$args->command,$t);364 }365 }366 return array('found'=>false);367 }368 369 function makeUrlQuery(&$args) # $parser, $command , $title370 {371 $params=array();372 for($i=2;$i<=$args->count; $i++)373 {374 if ($args->isNamed($i))375 {376 $name = $args->getName($i);377 if (!$this->removePrefix($name,'#')) $params[]=urlencode($name)."=".urlencode($args->trimExpandValue($i));378 }379 else break;380 }381 return join('&',$params);382 }383 function makeHtmlAttributes(&$args,$params=array()) # $parser, $command , $title384 {385 for($i=2;$i<=$args->count; $i++)386 {387 if ($args->isNamed($i))388 {389 $name = $args->getName($i);390 if ($this->removePrefix($name,'#')) $params[$name] = htmlspecialchars($args->trimExpandValue($i));391 }392 else break;393 }394 foreach ($params as $k=>$v)395 {396 $ret.="$k=\"$v\" ";397 }398 return $ret;399 }400 function makePath($t, $args) #$parser, $command, $title, $template;401 {402 $template=count($args)>3 ? $args[3] : false; 403 $prefix = "";404 $prefix.= $t->getNsText() ? $t->getNsText() . ":" : "";405 $pages = explode('/',$t->getText());406 $path.=array_shift($pages);407 $ret= $template ? '{{'.$template.'|'.$prefix.$path.'|'.$path.'}}' : "[[$prefix$path]]";408 foreach ($pages as $p)409 {410 $path .= "/$p";411 $ret .= $template ? '{{'.$template.'|'.$prefix.$path.'|'.$p.'}}' : "/[[$prefix$path|$p]]";412 }413 return $ret;414 }415 416 function shook_ShowMissingArticle ($a) {417 global $wgOut,$wgNamespacesWithSubpages;418 $t = $a->mTitle;419 if( isset( $wgNamespacesWithSubpages[ $t->getNamespace() ] ) && $wgNamespacesWithSubpages[ $t->getNamespace() ] ) {420 $parts = explode( '/', $t->getText(),2 );421 $wgOut->addWikiText('parts: ' . implode('|',$parts));422 $wgOut->disable();423 } 424 return false;425 }426}...

Full Screen

Full Screen

getNamespace

Using AI Code Generation

copy

Full Screen

1require_once 'Parser.php';2$parser = new Parser();3echo $parser->getNamespace();4require_once 'Parser.php';5$parser = new Parser();6echo $parser->getNamespace();7require_once 'Parser.php';8$parser = new Parser();9echo $parser->getNamespace();10require_once 'Parser.php';11$parser = new Parser();12echo $parser->getNamespace();13require_once 'Parser.php';14$parser = new Parser();15echo $parser->getNamespace();16require_once 'Parser.php';17$parser = new Parser();18echo $parser->getNamespace();19require_once 'Parser.php';20$parser = new Parser();21echo $parser->getNamespace();22require_once 'Parser.php';23$parser = new Parser();24echo $parser->getNamespace();25require_once 'Parser.php';26$parser = new Parser();27echo $parser->getNamespace();28require_once 'Parser.php';29$parser = new Parser();30echo $parser->getNamespace();31require_once 'Parser.php';32$parser = new Parser();33echo $parser->getNamespace();34require_once 'Parser.php';35$parser = new Parser();36echo $parser->getNamespace();37require_once 'Parser.php';38$parser = new Parser();39echo $parser->getNamespace();40require_once 'Parser.php';41$parser = new Parser();

Full Screen

Full Screen

getNamespace

Using AI Code Generation

copy

Full Screen

1require_once 'Parser.php';2$parser = new Parser();3echo $parser->getNamespace('1.php');4require_once 'Parser.php';5$parser = new Parser();6echo $parser->getNamespace('2.php');7require_once 'Parser.php';8$parser = new Parser();9echo $parser->getNamespace('3.php');10require_once 'Parser.php';11$parser = new Parser();12echo $parser->getNamespace('4.php');13require_once 'Parser.php';14$parser = new Parser();15echo $parser->getNamespace('5.php');16require_once 'Parser.php';17$parser = new Parser();18echo $parser->getNamespace('6.php');19require_once 'Parser.php';20$parser = new Parser();21echo $parser->getNamespace('7.php');22require_once 'Parser.php';23$parser = new Parser();24echo $parser->getNamespace('8.php');25require_once 'Parser.php';26$parser = new Parser();27echo $parser->getNamespace('9.php');28require_once 'Parser.php';29$parser = new Parser();30echo $parser->getNamespace('10.php');31require_once 'Parser.php';32$parser = new Parser();33echo $parser->getNamespace('11.php');34require_once 'Parser.php';35$parser = new Parser();36echo $parser->getNamespace('12.php');37require_once 'Parser.php';38$parser = new Parser();

Full Screen

Full Screen

getNamespace

Using AI Code Generation

copy

Full Screen

1require_once 'Parser.php';2$parser = new Parser();3echo $parser->getNamespace(file_get_contents('1.php'));4require_once 'Parser.php';5$parser = new Parser();6echo $parser->getNamespace(file_get_contents('2.php'));7namespace App;8namespace App\Sub;9ReflectionClass::getNamespaceName()10ReflectionClass::getNamespaceName()11namespace App;12namespace App\Sub;13require_once '1.php';14require_once '2.php';15$reflector = new ReflectionClass('App');16echo $reflector->getNamespaceName();17$reflector = new ReflectionClass('App\Sub');18echo $reflector->getNamespaceName();19PHP ReflectionClass::getNamespaceName()20PHP ReflectionClass::getShortName()21PHP ReflectionClass::getName()22PHP ReflectionClass::getFileName()23PHP ReflectionClass::getStartLine()24PHP ReflectionClass::getEndLine()25PHP ReflectionClass::getConstants()26PHP ReflectionClass::getConstructor()27PHP ReflectionClass::getDefaultProperties()28PHP ReflectionClass::getMethods()29PHP ReflectionClass::getProperties()30PHP ReflectionClass::getInterfaces()31PHP ReflectionClass::getTraits()32PHP ReflectionClass::getTraitAliases()33PHP ReflectionClass::getTraitNames()34PHP ReflectionClass::getInterfaceNames()35PHP ReflectionClass::isInterface()36PHP ReflectionClass::isTrait()37PHP ReflectionClass::isAbstract()38PHP ReflectionClass::isFinal()39PHP ReflectionClass::isInstantiable()40PHP ReflectionClass::isCloneable()

Full Screen

Full Screen

getNamespace

Using AI Code Generation

copy

Full Screen

1require_once('Parser.php');2$parser = new Parser();3$parser->getNamespace('1.php');4require_once('Parser.php');5$parser = new Parser();6$parser->getNamespace('2.php');7require_once('Parser.php');8$parser = new Parser();9$parser->getNamespace('3.php');10require_once('Parser.php');11$parser = new Parser();12$parser->getNamespace('4.php');13require_once('Parser.php');14$parser = new Parser();15$parser->getNamespace('5.php');16require_once('Parser.php');17$parser = new Parser();18$parser->getNamespace('6.php');19require_once('Parser.php');20$parser = new Parser();21$parser->getNamespace('7.php');22require_once('Parser.php');23$parser = new Parser();24$parser->getNamespace('8.php');25require_once('Parser.php');26$parser = new Parser();27$parser->getNamespace('9.php');28require_once('Parser.php');29$parser = new Parser();30$parser->getNamespace('10.php');31require_once('Parser.php');32$parser = new Parser();33$parser->getNamespace('11.php');34require_once('Parser.php');35$parser = new Parser();36$parser->getNamespace('12.php');37require_once('Parser.php');38$parser = new Parser();39$parser->getNamespace('13.php');

Full Screen

Full Screen

getNamespace

Using AI Code Generation

copy

Full Screen

1require_once 'Parser.php';2$parser = new Parser();3$namespace = $parser->getNamespace("1.php");4echo $namespace;5require_once 'Parser.php';6$parser = new Parser();7$namespace = $parser->getNamespace("2.php");8echo $namespace;9require_once 'Parser.php';10$parser = new Parser();11$namespace = $parser->getNamespace("3.php");12echo $namespace;13require_once 'Parser.php';14$parser = new Parser();15$namespace = $parser->getNamespace("4.php");16echo $namespace;17require_once 'Parser.php';18$parser = new Parser();19$namespace = $parser->getNamespace("5.php");20echo $namespace;21require_once 'Parser.php';22$parser = new Parser();23$namespace = $parser->getNamespace("6.php");24echo $namespace;25require_once 'Parser.php';26$parser = new Parser();27$namespace = $parser->getNamespace("7.php");28echo $namespace;29require_once 'Parser.php';30$parser = new Parser();31$namespace = $parser->getNamespace("8.php");32echo $namespace;33require_once 'Parser.php';34$parser = new Parser();35$namespace = $parser->getNamespace("9.php");36echo $namespace;37require_once 'Parser.php';38$parser = new Parser();39$namespace = $parser->getNamespace("10.php");40echo $namespace;41require_once 'Parser.php';42$parser = new Parser();43$namespace = $parser->getNamespace("11.php");44echo $namespace;

Full Screen

Full Screen

getNamespace

Using AI Code Generation

copy

Full Screen

1namespace Test;2echo "Hello World";3?>';4$parser = new PHPParser_Parser(new PHPParser_Lexer);5$traverser = new PHPParser_NodeTraverser;6$prettyPrinter = new PHPParser_PrettyPrinter_Default;7$traverser->addVisitor(new PHPParser_NodeVisitor_NameResolver);8try {9 $stmts = $parser->parse($code);10 $stmts = $traverser->traverse($stmts);11} catch (PHPParser_Error $e) {12 echo 'Parse Error: ', $e->getMessage();13}14$namespace = $stmts[0]->getNamespace();15echo $namespace->toString(), "16";17namespace Test;

Full Screen

Full Screen

getNamespace

Using AI Code Generation

copy

Full Screen

1require_once 'Parser.php';2$parser = new Parser();3$parser->getNamespace("namespace A\B\C;");4require_once 'Parser.php';5$parser = new Parser();6$parser->getNamespace("namespace A\B\C;");7require_once 'Parser.php';8$parser = new Parser();9$parser->getNamespace("namespace A\B\C;");10require_once 'Parser.php';11$parser = new Parser();12$parser->getNamespace("namespace A\B\C;");13require_once 'Parser.php';14$parser = new Parser();15$parser->getNamespace("namespace A\B\C;");16require_once 'Parser.php';17$parser = new Parser();18$parser->getNamespace("namespace A\B\C;");19require_once 'Parser.php';20$parser = new Parser();21$parser->getNamespace("namespace A\B\C;");22require_once 'Parser.php';23$parser = new Parser();24$parser->getNamespace("namespace A\B\C;");25require_once 'Parser.php';26$parser = new Parser();27$parser->getNamespace("namespace A\B\C;");28require_once 'Parser.php';29$parser = new Parser();30$parser->getNamespace("namespace A\B\C;");

Full Screen

Full Screen

getNamespace

Using AI Code Generation

copy

Full Screen

1include_once 'Parser.php';2$parser = new Parser();3$namespace = $parser->getNamespace();4echo $namespace;5include_once 'Parser.php';6$parser = new Parser();7$namespace = $parser->getNamespace('My\Namespace\Path\Parser');8echo $namespace;9include_once 'Parser.php';10$parser = new Parser();11$namespace = $parser->getNamespace('Parser.php');12echo $namespace;13include_once 'Parser.php';14$parser = new Parser();15$namespace = $parser->getNamespace('My\Namespace\Path\Parser2');16echo $namespace;17include_once 'Parser.php';18$parser = new Parser();19$namespace = $parser->getNamespace('Parser2.php');20echo $namespace;21include_once 'Parser.php';22$parser = new Parser();23$namespace = $parser->getNamespace('Parser');24echo $namespace;25include_once 'Parser.php';26$parser = new Parser();27$namespace = $parser->getNamespace('Parser.php');28echo $namespace;

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful