Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
29a7eb7
commit 550a992
Showing
9 changed files
with
715 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
/* | ||
* Mondrian | ||
*/ | ||
|
||
namespace Trismegiste\Mondrian\Visitor\Edge; | ||
|
||
use PhpParser\Node\Stmt; | ||
|
||
/** | ||
* ClassLevel is ... | ||
*/ | ||
class ClassLevel extends ObjectLevelHelper | ||
{ | ||
|
||
public function enter(\PhpParser\Node $node) | ||
{ | ||
|
||
} | ||
|
||
public function getName() | ||
{ | ||
return 'class'; | ||
} | ||
|
||
} |
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,33 @@ | ||
<?php | ||
|
||
/* | ||
* Mondrian | ||
*/ | ||
|
||
namespace Trismegiste\Mondrian\Visitor\Edge; | ||
|
||
use Trismegiste\Mondrian\Visitor\VisitorGateway; | ||
use Trismegiste\Mondrian\Transform\ReflectionContext; | ||
use Trismegiste\Mondrian\Transform\GraphContext; | ||
use Trismegiste\Mondrian\Graph\Graph; | ||
|
||
/** | ||
* Collector is ... | ||
*/ | ||
class Collector extends VisitorGateway | ||
{ | ||
|
||
public function __construct(ReflectionContext $ref, GraphContext $grf, Graph $g) | ||
{ | ||
$visitor = [ | ||
new \Trismegiste\Mondrian\Visitor\State\PackageLevel(), | ||
new FileLevel(), | ||
new ClassLevel(), | ||
new InterfaceLevel(), | ||
new TraitLevel() | ||
]; | ||
|
||
parent::__construct($visitor, $ref, $grf, $g); | ||
} | ||
|
||
} |
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,55 @@ | ||
<?php | ||
|
||
/* | ||
* Mondrian | ||
*/ | ||
|
||
namespace Trismegiste\Mondrian\Visitor\Edge; | ||
|
||
use Trismegiste\Mondrian\Visitor\State\FileLevelTemplate; | ||
use PhpParser\Node\Stmt; | ||
|
||
/** | ||
* FileLevel is ... | ||
*/ | ||
class FileLevel extends FileLevelTemplate | ||
{ | ||
|
||
protected function enterClassNode(Stmt\Class_ $node) | ||
{ | ||
$fqcn = $this->getNamespacedName($node); | ||
$src = $this->findVertex('class', $fqcn); | ||
|
||
// extends | ||
if (!is_null($node->extends)) { | ||
if (null !== $dst = $this->findVertex('class', (string) $this->resolveClassName($node->extends))) { | ||
$this->getGraph()->addEdge($src, $dst); | ||
} | ||
} | ||
// implements | ||
foreach ($node->implements as $interf) { | ||
if (null !== $dst = $this->findVertex('interface', (string) $this->resolveClassName($interf))) { | ||
$this->getGraph()->addEdge($src, $dst); | ||
} | ||
} | ||
} | ||
|
||
protected function enterInterfaceNode(Stmt\Interface_ $node) | ||
{ | ||
$fqcn = $this->getNamespacedName($node); | ||
$src = $this->findVertex('interface', $fqcn); | ||
|
||
// implements | ||
foreach ($node->extends as $interf) { | ||
if (null !== $dst = $this->findVertex('interface', (string) $this->resolveClassName($interf))) { | ||
$this->getGraph()->addEdge($src, $dst); | ||
} | ||
} | ||
} | ||
|
||
protected function enterTraitNode(Stmt\Trait_ $node) | ||
{ | ||
|
||
} | ||
|
||
} |
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,27 @@ | ||
<?php | ||
|
||
/* | ||
* Mondrian | ||
*/ | ||
|
||
namespace Trismegiste\Mondrian\Visitor\Edge; | ||
|
||
use PhpParser\Node\Stmt; | ||
|
||
/** | ||
* InterfaceLevel is ... | ||
*/ | ||
class InterfaceLevel extends ObjectLevelHelper | ||
{ | ||
|
||
public function enter(\PhpParser\Node $node) | ||
{ | ||
|
||
} | ||
|
||
public function getName() | ||
{ | ||
return 'interface'; | ||
} | ||
|
||
} |
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,17 @@ | ||
<?php | ||
|
||
/* | ||
* Mondrian | ||
*/ | ||
|
||
namespace Trismegiste\Mondrian\Visitor\Edge; | ||
|
||
use Trismegiste\Mondrian\Visitor\State\AbstractObjectLevel; | ||
|
||
/** | ||
* ObjectLevelHelper is | ||
*/ | ||
abstract class ObjectLevelHelper extends AbstractObjectLevel | ||
{ | ||
|
||
} |
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,27 @@ | ||
<?php | ||
|
||
/* | ||
* Mondrian | ||
*/ | ||
|
||
namespace Trismegiste\Mondrian\Visitor\Edge; | ||
|
||
use PhpParser\Node\Stmt; | ||
|
||
/** | ||
* TraitLevel is ... | ||
*/ | ||
class TraitLevel extends ObjectLevelHelper | ||
{ | ||
|
||
public function enter(\PhpParser\Node $node) | ||
{ | ||
|
||
} | ||
|
||
public function getName() | ||
{ | ||
return 'trait'; | ||
} | ||
|
||
} |
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
Oops, something went wrong.