-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to pass an array of files instead of a single file
Generally we have multiple changed files, so this makes it easier to use that.
- Loading branch information
BackEndTea
committed
Aug 10, 2019
1 parent
c985187
commit f424926
Showing
5 changed files
with
65 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace Depend\Test\PHPParser\Visitor; | ||
|
||
use Depend\PHPParser\Visitor\DeclarationCollector; | ||
use Depend\PHPParser\Visitor\NameCollector; | ||
use Depend\PHPParser\Visitor\ParentConnectorVisitor; | ||
use PhpParser\NodeTraverser; | ||
use PhpParser\NodeVisitor\NameResolver; | ||
use PhpParser\ParserFactory; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class DeclarationCollectorTest extends TestCase | ||
{ | ||
|
||
public function testItFindsAllDeclaredNames(): void | ||
{ | ||
$parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7); | ||
$nodes = $parser->parse(<<<'PHP' | ||
<?php | ||
namespace F; | ||
class Foo | ||
{ | ||
public function __construct(Bar\Baz $a) {} | ||
public function hello(\Full\Name $b): string | ||
{ | ||
return false; | ||
} | ||
} | ||
interface B{} | ||
PHP | ||
); | ||
$traverser = new NodeTraverser(); | ||
$traverser->addVisitor(new NameResolver()); | ||
$traverser->addVisitor(new ParentConnectorVisitor()); | ||
$declareCollector = new DeclarationCollector(); | ||
$traverser->addVisitor($declareCollector); | ||
$traverser->traverse($nodes); | ||
|
||
$this->assertCount(2, $declareCollector->declared); | ||
$this->assertSame([ | ||
'F\Foo', | ||
'F\B', | ||
], $declareCollector->declared); | ||
} | ||
|
||
} |